当前位置:Gxlcms > PHP教程 > phalcon

phalcon

时间:2021-07-01 10:21:17 帮助过:20人阅读

这两天研究phalcon, 感觉mysql查询很慢啊, 是我写的不对吗

bootstrap

 $this->_di->setShared('dbSlave', function () use ($config) {
            return new Mysql(array(
                "host"     => $config->dbSlave->host,
                "username" => $config->dbSlave->username,
                "password" => $config->dbSlave->password,
                "dbname"   => $config->dbSlave->name
            ));
        });
$b = Users::findFirst([
        'id = :bid:',
        'bind' => ['bid' => 1]
    ]);
    echo $b->name;

感觉查询卡了一两秒

回复内容:

这两天研究phalcon, 感觉mysql查询很慢啊, 是我写的不对吗

bootstrap

 $this->_di->setShared('dbSlave', function () use ($config) {
            return new Mysql(array(
                "host"     => $config->dbSlave->host,
                "username" => $config->dbSlave->username,
                "password" => $config->dbSlave->password,
                "dbname"   => $config->dbSlave->name
            ));
        });
$b = Users::findFirst([
        'id = :bid:',
        'bind' => ['bid' => 1]
    ]);
    echo $b->name;

感觉查询卡了一两秒

MySQL用bind-address = 127.0.0.1限制只能本地访问时,Windows7上PHP用localhost访问MySQL明显变慢,用127.0.0.1则正常.

我用phalcon不会啊,你用php原生的mysqli查询一次看看需要多久。和你php服务器和mysql服务器之间的连接速度也有关系。

人气教程排行