I want to check a record is exists, so I use query in the model
if ($record = static::query()->where('email = "'.$this->email.'"')->andWhere("id != " . $this->id)->execute()) {
}
here is the sql log
[Mon, 04 Sep 17 08:09:23 +0000][INFO] SELECT `users`.`id`, `users`.`uid`, `users`.`username`, `users`.`email`, `users`.`emailValid`, `users`.`phone`, `users`.`phoneValid`, `users`.`password`, `users`.`aid`, `users`.`status`, `users`.`created_at`, `users`.`updated_at` FROM `users` WHERE (`users`.`email` = '[email protected]') AND (`users`.`id` <> 7)
print_r($record)
Phalcon\Mvc\Model\Resultset\Simple Object
(
[_result:protected] =>
[_cache:protected] =>
[_isFresh:protected] => 1
[_pointer:protected] => 0
[_count:protected] => 0
[_activeRow:protected] =>
[_rows:protected] => Array
(
)
[_row:protected] =>
[_errorMessages:protected] =>
[_hydrateMode:protected] => 0
[_model:protected] => app\models\Users Object
(
[aid] =>
[id] =>
[uid] =>
[username] =>
[email] =>
[emailValid] =>
[phone] =>
[phoneValid] =>
[password] =>
[status] =>
[_dependencyInjector:protected] => Phalcon\Di\FactoryDefault Object
why $record
not empty, but return a model with null of field
Phalcon DevTools (3.2.0)
Environment:
OS: Darwin MacBook-Pro.local 15.6.0 Darwin Kernel Version 15.6.0: Sun Jun 4 21:43:07 PDT 2017; root:xnu-3248.70.3~1/RELEASE_X86_64 x86_64
PHP Version: 7.0.22
PHP SAPI: cli
PHP Bin: /usr/local/Cellar/php70/7.0.22_14/bin/php
PHP Extension Dir: /usr/local/Cellar/php70/7.0.22_14/lib/php/extensions/no-debug-non-zts-20151012
PHP Bin Dir: /usr/local/Cellar/php70/7.0.22_14/bin
Loaded PHP config: /usr/local/etc/php/7.0/php.ini
Versions:
Phalcon DevTools Version: 3.2.0
Phalcon Version: 3.2.0
AdminLTE Version: 2.3.6