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

model::find() is not data, but raw select sql can find data,why?

model::find() is not data, but raw select sql can find data,why?

Can you show us the code for the two variants?



933

use Phalcon\Mvc\Controller;

class TestController extends Controller {

public function searchAction()
{
    $res = $this->db->fetchOne('select * from products');
    echo "<pre>";
    var_dump($res);
    echo "</pre>";

    $data = Products::find();
    echo "<pre>";
    var_dump($data->count());
    echo "</pre>";
}

}

code is above ,raw sql is use, but Products model can't find data.

Can you show us the code for the two variants?



933

How can I debug the strange question? help

edited Oct '16

What you mean can't find data ? What problem you have exactly ? Check php logs. Also add mysql logging(from mysql or framework on beforeQuery).



933
edited Oct '16

Prior to the project in the 2.0.11 Phalcon version can be normal operation, the query results are returned. But after the transfer to the 2.0.13 Phalcon version, the results of the Phalcon query data are empty, check the query usage is not wrong, print out the implementation of the SQL statement and the database can be found in the corresponding data. What is the reason? Add, delete operations are not fully, but the query results are empty data. php version 5.6.9

Check php logs. Also Phalcon 2.0 is no longer supported. Enable sql logging using phalcon or enable it in mysql and check if queries are happening on ::find