I'm encountering a strange problem with doctrine and named parameters.
Here is a query which actually works perfectly with this set of parameters (dynamic in my code):
$params = array( ':id_editeur' => 1,
':nom_editeur' => 'Test');
public function updateById($params)
{
Doctrine_Query::create()
->update('Editeur e')
->set('e.nom_editeur', ':nom_editeur')
->where('e.id_editeur = :id_editeur')
->execute($params);
}
Now i have another function
public function findAll($params)
{
$query = Doctrine_Query::create()
->from('Editeur e')
->orderBy(':orderby')
->limit(':limit')
->offset(':offset');
return $query->execute($params);
}
With these parameters:
$params = array( ':orderby' => ('e.id_editeur ASC'),
':limit' => (10),
':offset' => (20));
And even if it's the same mechanism i get the following error
Invalid parameter number: number of bound variables does not match number of tokens
Any idea of the reason? By the way, it works if I fill the orderby, limit and offset directly in the function in the classical way.
The params var cannot contain ":" character...
Try replacing:
$params = array( ':id_editeur' => 1,
':nom_editeur' => 'Test');
to:
$params = array( 'id_editeur' => 1,
'nom_editeur' => 'Test');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With