Maison >développement back-end >tutoriel php >phalcon
这两天研究phalcon, 感觉mysql查询很慢啊, 是我写的不对吗
bootstrap
<code> $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 )); });</code>
<code>$b = Users::findFirst([ 'id = :bid:', 'bind' => ['bid' => 1] ]); echo $b->name;</code>
感觉查询卡了一两秒
这两天研究phalcon, 感觉mysql查询很慢啊, 是我写的不对吗
bootstrap
<code> $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 )); });</code>
<code>$b = Users::findFirst([ 'id = :bid:', 'bind' => ['bid' => 1] ]); echo $b->name;</code>
感觉查询卡了一两秒
MySQL用bind-address = 127.0.0.1限制只能本地访问时,Windows7上PHP用localhost访问MySQL明显变慢,用127.0.0.1则正常.
我用phalcon不会啊,你用php原生的mysqli查询一次看看需要多久。和你php服务器和mysql服务器之间的连接速度也有关系。