phalcon
程序员文章站
2022-05-20 09:08:01
...
这两天研究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服务器之间的连接速度也有关系。
下一篇: php默许查找的页面