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

Hidden error - alternating tables for sample

We have the following code:

public function indexAction()
    {
        $c = new UserModel();
        $this->logger->info("Class: ".get_class($c));
        $this->view->setVar('user_count', UserModel::count());
    }

As a result, we see the following log:

[Mon, 13 Apr 15 14:23:26 +0300][INFO] Class: Admin\Model\UserModel
[Mon, 13 Apr 15 14:23:26 +0300][INFO] SELECT COUNT(*) AS 'rowcount' FROM ml_user

its good. Next run update page? log:

[Mon, 13 Apr 15 14:24:25 +0300][INFO] Class: Admin\Model\UserModel
[Mon, 13 Apr 15 14:24:25 +0300][INFO] SELECT COUNT(*) AS rowcount FROM ml_plugins_events

ml plugins events - WTF???
in one model can change the table if it is statically spelled ??

PS: MySQL 5.5.41, PHP 5.5.9, Phalcon 1.3.4

Help I have a week trying to fix it :(



125.8k
Accepted
answer

Where/when is that second output being generated? Is it on the same action?

Phalcon does LOTS of selecting for what would seem to be simple tasks - maybe the query you expect to be seeing is in the log somewhere, just buried.



914
edited Apr '15

Where/when is that second output being generated? Is it on the same action?

Phalcon does LOTS of selecting for what would seem to be simple tasks - maybe the query you expect to be seeing is in the log somewhere, just buried.

Yes, I always run the same action in the controller. Enabled cache meta data models. Today launched disable all plug-ins one by one, it turned out error occurs only after the code

use Phalcon\Mvc\User\Plugin;

class UserPlugin extends Plugin
{
    /** UserModel */
    private $_user = false;

    public function __construct()
    {
        if ($this->persistent->has('user'))
            $this->_user = $this->persistent->user;
    }
    /**
     * @param UserModel $user
     */
    public function login($user)
    {
       $this->persistent->user = $user; // this not serialize
    }
}

I removed the storage model and made only persistent storage fields, the error is no longer observed, but whether this was the reason?