PDO fails to prepare a statement with over 13 placeholders
Posted
by Javier Parra
on Stack Overflow
See other posts from Stack Overflow
or by Javier Parra
Published on 2010-03-16T17:16:21Z
Indexed on
2010/03/16
17:21 UTC
Read the original article
Hit count: 373
Hello, this is the code I'm using:
self::$DB->prepare($query, $types);
when the $query and types are:
//$query
UPDATE Permisos
SET
empleado_id = ?,
agregar_mensaje = ?,
borrar_mensaje = ?,
agregar_noticia = ?,
borrar_noticia = ?,
agregar_documento = ?,
borrar_documento = ?,
agregar_usuario = ?,
borrar_usuario = ?,
agregar_empresa = ?,
borrar_empresa = ?,
agregar_tarea = ?
WHERE
id = ?
//$types
Array(
[0] => integer
[1] => boolean
[2] => boolean
[3] => boolean
[4] => boolean
[5] => boolean
[6] => boolean
[7] => boolean
[8] => boolean
[9] => boolean
[10] => boolean
[11] => boolean
[12] => integer
)
Everything works great, but when they are:
//$query
UPDATE Permisos SET
empleado_id = ?,
agregar_mensaje = ?,
borrar_mensaje = ?,
agregar_noticia = ?,
borrar_noticia = ?,
agregar_documento = ?,
borrar_documento = ?,
agregar_usuario = ?,
borrar_usuario = ?,
agregar_empresa = ?,
borrar_empresa = ?,
agregar_tarea = ?,
borrar_tarea = ?
WHERE
id = ?
//$types
Array(
[0] => integer
[1] => boolean
[2] => boolean
[3] => boolean
[4] => boolean
[5] => boolean
[6] => boolean
[7] => boolean
[8] => boolean
[9] => boolean
[10] => boolean
[11] => boolean
[12] => boolean
[13] => integer
)
It fails with the following message:
<b>Warning</b>: PDO::prepare() [<a href='pdo.prepare'>pdo.prepare</a>]: SQLSTATE[HY000]: General error: PDO::ATTR_STATEMENT_CLASS requires format array(classname, array(ctor_args)); the classname must be a string specifying an existing class in <b>C:\wamp\www\intratin\JP\includes\empleado\mapper\Permiso.php</b> on line <b>137</b><br />
Doesn't matter which field I add or remove, it fails every time with more than 13 placeholders.
© Stack Overflow or respective owner