Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Literals and magic methods #886

Closed
hesalx opened this issue Jul 19, 2013 · 3 comments
Closed

Literals and magic methods #886

hesalx opened this issue Jul 19, 2013 · 3 comments
Labels
bug A bug report status: medium Medium

Comments

@hesalx
Copy link

hesalx commented Jul 19, 2013

It is a bit strange, but you can't use model's magic methods (like Model::findById($id)) with literals disabled.

Even findFirst() with bind and conditions doesn't work! Only basic find() does.
o_O

Phalcon\Mvc\Model\Exception: Literals are disabled in PHQL statements
#0  Phalcon\Mvc\Model\Query->parse()
#1  Phalcon\Mvc\Model\Query->execute(Array([id] => 0), null)
#2  Phalcon\Mvc\Model::findFirst(Array([conditions] => id = :id:, [bind] => Array([id] => 0)))
$user = Model\User::findFirst([
    "conditions" => "id = :id:", 
    "bind" => ["id" => $id]
]);

I thought magic methods are completely safe, aren't they?

@dreamsxin
Copy link
Contributor

Think I am not wrong.

$account = Accounts::findFirst(array(
    'conditions' => 'id = :id:',
    'bind' => ['id' => 2]
));

Can look like Model \ User defined it?

@phalcon
Copy link
Collaborator

phalcon commented Jul 22, 2013

This is happening because of the LIMIT 1 at the end of the query :/

@ghost
Copy link

ghost commented Feb 2, 2014

This has been fixed, could you please check and close the bug if everything works for you?

@niden niden added bug A bug report status: medium Medium and removed Bug - Medium labels Dec 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug report status: medium Medium
Projects
None yet
Development

No branches or pull requests

3 participants