Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Binding parameters to QueryBuilder


I'm trying to bind some parameters with Phalcon\Mvc\Model\Query\Builder::where method.

This is my code:

$builder = $this->modelsManager->createBuilder()
    ->addFrom('\Namespace\Model', 'm')
    ->where('', array('id' => $id));

But it produces the following error:

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':id' at line 1

What am I doing wrong?

edited Oct '14

Unfortunately 'where' has no second parameter. To bind values use:

$builder = $this->modelsManager->createBuilder()
    ->addFrom('\Namespace\Model', 'm')
    ->execute(array('id' => $id))

Sorry, I forgot to mention that I'm using Phalcon 1.1.0.

In Phalcon 1.1.0 there are two more parameters on where method:

It seems that implementation is missing while andWhere (and other) has this implementation


Hi, I added a fix for this in 1.1.0, can you recompile again please?

Problem solved! :) Thank you @Phalcon