DbAdapter query parameters in PDO
Opened this issue · 3 comments
Deleted user commented
$dbAdapter->query('SET @@session.time_zone = :tz', [
':tz' => $timeZoneName,
]);
After #224, this line throws an error "Invalid parameter number: parameter was not defined"
Deleted user commented
This method changes param name before binding, but do not change it in query string
/**
* @param string $name
* @param string|null $type
* @return string
*/
public function formatParameterName($name, $type = null)
{
if ($type === null && ! is_numeric($name) || $type == self::PARAMETERIZATION_NAMED) {
// using MD5 because of the PDO restriction [A-Za-z0-9_] for bindParam name
return ':' . md5($name);
}
return '?';
}
Ocramius commented
@ArtemChornovol scenario above needs tests - not sure what formatParameterName
is supposed to help with here.
ezimuel commented