We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Модели в Phalcon/Model in Phalcon

Друзья, подскажите, почему не работает код:

$user = User::findFirst(['email' => $email, 'active' => '1']);

При любом $email возвращается первая запись в таблице. Если же использовать данный код:

$user = User::findFirst([
                'conditions'    => 'email = :email: AND active="1"',
                'bind'          => [
                    'email'         => $data['email'],
                ],
]);

все работает правильно. Что не так?


Guys, tell me, why this code is not working?

$user = User::FindFirst (['email' => $ email, 'activo' => '1']); 

For any email it returns the first record of the table. If I use this code:

$user = User::findFirst([
                'conditions'    => 'email = :email: AND active="1"',
                'bind'          => [
                    'email'         => $data['email'],
                ],
]);

Everything works properly. What is happening/what is wrong?



98.9k

This syntax:

$user = User::FindFirst (['email' => $ email, 'activo' => '1']);

It isn't supported by the ORM. You can see the supported syntax in the documentation: https://docs.phalcon.io/es/latest/reference/models.html#finding-records