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.

forUpdate - doesn't work

Hello All.

I found bug in ORM, I think.

I use profiler to view all queries in page. If I use pure sql query:

$phql = "SELECT * FROM general_table where key = '$key' FOR UPDATE;";
$row = Phalcon\DI::getDefault()->getShared('db')->query($phql)->fetch();

logger showes to me - 'SELECT * FROM general_table where key = 'abc' FOR UPDATE;'

If I use model:

$row = Model\General\GeneralTable::findFirst(
                "limit" => 1,
                "conditions" => 'key= :key:',
                "bind" => array('key'=>$key),
                "for_update" => true

logger showes only: 'SELECT * FROM general_table WHERE key = 'abc'

It's means "FOR UPDATE" doesn't append to query.

Can somebody help to me???

UPDATE: Phalcon 1.3.2

edited May '14

There's 3 ways to do that query, you can try using builder or criteria:

    $row = Model\General\GeneralTable::query()
        ->where('key= :key:', array('key'=>$key))


I've also experimented some un implemented features in the ORM. Maybe ask that as NFR on github ...

Sorry, I forgot write about 3rd way - its also doesn't work.