You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.
$stmt = $adapter->query("SELECT CAST(:num AS INT) AS num");
//first invocation
$params = new ParameterContainer();
$params->offsetSet('num', 1);
echo $stmt->execute($params)->current()['num'] . PHP_EOL;
//second invocation
$params = new ParameterContainer();
$params->offsetSet('num', 2);
echo $stmt->execute($params)->current()['num'] . PHP_EOL;
output:
1
1
Looking at zend-db/Zend/Db/Adapter/Statement.php line 216 and subsequent:
/** START Standard ParameterContainer Merging Block */
if (!$this->parameterContainer instanceof ParameterContainer) {
if ($parameters instanceof ParameterContainer) {
$this->parameterContainer = $parameters;
$parameters = null;
} else {
$this->parameterContainer = new ParameterContainer();
}
}
if (is_array($parameters)) {
$this->parameterContainer->setFromArray($parameters);
}
if ($this->parameterContainer->count() > 0) {
$this->bindParametersFromContainer();
}
/** END Standard ParameterContainer Merging Block */
$this->parameterContainer is not overwritten, unless either
(a) it is not a ParameterContainer instance
(b) the $parameters passed to the function is an array
During the second invocation, neither of the above is true, so the new parameters are simply ignored and the old ones are used.
The above should look like this IMHO:
/** START Standard ParameterContainer Merging Block */
if ($parameters instanceof ParameterContainer) {
$this->parameterContainer = $parameters;
$parameters = null;
} else if (!$this->parameterContainer instanceof ParameterContainer) {
$this->parameterContainer = new ParameterContainer();
}
if (is_array($parameters)) {
$this->parameterContainer->setFromArray($parameters);
}
if ($this->parameterContainer->count() > 0) {
$this->bindParametersFromContainer();
}
/** END Standard ParameterContainer Merging Block */
The text was updated successfully, but these errors were encountered:
$stmt = $adapter->query("SELECT CAST(:num AS INT) AS num"); //first invocation $params = new ParameterContainer(); $params->offsetSet('num', 1); echo $stmt->execute($params)->current()['num'] . PHP_EOL; //second invocation $params = new ParameterContainer(); $params->offsetSet('num', 2); echo $stmt->execute($params)->current()['num'] . PHP_EOL;
output:
1
1
Looking at zend-db/Zend/Db/Adapter/Statement.php line 216 and subsequent:
/** START Standard ParameterContainer Merging Block */
if (!$this->parameterContainer instanceof ParameterContainer) {
if ($parameters instanceof ParameterContainer) {
$this->parameterContainer = $parameters;
$parameters = null;
} else {
$this->parameterContainer = new ParameterContainer();
}
}
$this->parameterContainer is not overwritten, unless either
(a) it is not a ParameterContainer instance
(b) the $parameters passed to the function is an array
During the second invocation, neither of the above is true, so the new parameters are simply ignored and the old ones are used.
The above should look like this IMHO:
/** START Standard ParameterContainer Merging Block */
if ($parameters instanceof ParameterContainer) {
$this->parameterContainer = $parameters;
$parameters = null;
} else if (!$this->parameterContainer instanceof ParameterContainer) {
$this->parameterContainer = new ParameterContainer();
}
The text was updated successfully, but these errors were encountered: