zendframework/zf2 — pull request #4967 by MarcelTO (2013-08-15 21:52:29+00:00)
Title: Sqlsrv varbinary and statement options support

These changes to allow varbinary fields to be updated with parameter container or by passing an array as shown below.

$container = new ParameterContainer;
$container->offsetSet('PLAN_DOC', $file_stream);
$container->offsetSet('ID', $id);
$container->offsetSetErrata('PLAN_DOC', $container::TYPE_BINARY);

or

$params = array(
array(
&$file_stream,
\SQLSRV_PARAM_IN,
\SQLSRV_PHPTYPE_STREAM(\SQLSRV_ENC_BINARY),
\SQLSRV_SQLTYPE_VARBINARY('max')
),
$id
);

$result = $statement->execute($params);

*Please note that both methods are order sensitive and any parameter names used must be unique.

A new TableGateway feature was also added to allow for different Sqlsrv cursor types to be used with different types of sql statements. This resolves an issue with the ResultSet count method (sqlsrv_num_rows) which doesn't return properly with the default cursor type. There may be a better way of using the feature, however, the one shown below should work.

$tableGateway = new TableGateway($this->table, $this->adapter, null, $resultSetPrototype);

$featureSet = $tableGateway->getFeatureSet();
$featureSet->addFeature(new \Zend\Db\TableGateway\Feature\StatementOptionsFeature);

$feature = $featureSet->getFeatureByClassName('\Zend\Db\TableGateway\Feature\StatementOptionsFeature');
$feature->setTableGateway($tableGateway);