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

::find() and findFirst() return null, why? help!!!

my table column is:

| id | typesId | name | price | quantity | status |

my model code is:

class Products extends \Phalcon\Mvc\Model {

public $id; 
public $typesId;
public $name;
public $price;  
public $quantity;
public $status;

public function getSource()
{
    return 'products';
}
public static function find($parameters = null)
{
    return parent::find($parameters);
}
public static function findFirst($parameters = null)
{
    return parent::findFirst($parameters);
}

}

when i use this code:

$data = Products::find();

var_dump($data);

the variable $data was NULL, why?

I need help,thank you

PHP VERSION: 5.6.9 phalcon version : 2.0.13



85.5k

do you have anything in this table ?

edited Oct '16

Find should return always resultset i think, if there is no data there just will be no data in it, but should return object, not sure what's going on here. Just best update phalcon to 3.0



982

you are right, I check my version of php extention and find the version of the pdo_mysql is 5.5.42, which could be the problem I think.

Find should return always resultset i think, if there is no data there just will be no data in it, but should return object, not sure what's going on here. Just best update phalcon to 3.0

perhaps the column 'status' is a keyword.