为啥这个路由只能响应一次,第二次再刷新浏览器,就出现 500 错误。打开错误提示,提示 mysql 访问拒绝因为没有密码,但是里面明明写了密码啊,而且第一次就行。
$app->post('/mysql1',function () {
$connection = new \Phalcon\Db\Adapter\Pdo\Mysql(array( "host" => "localhost", "username" => "root", "password" => "123", "dbname" => "test" )); //print_r(get_class_methods($connection)); //从支持的方法上看,只不过是在 PDO 上扩展了一些功能 $connection->query('set names utf8'); $t = $connection->fetchAll('select * from typecho_comments order by author limit 1500'); print_r($t);
});
为啥这个路由只能响应一次,第二次再刷新浏览器,就出现 500 错误。打开错误提示,提示 mysql 访问拒绝因为没有密码,但是里面明明写了密码啊,而且第一次就行。
Fatal error: Uncaught PDOException: SQLSTATE[HY000] [1045] Access denied for user ''@'localhost' (using password: NO) in /web/phalcon7/public/index.php:15 Stack trace: #0 [internal function]: PDO->__construct('mysql:host=loca...', NULL, NULL, Array) #1 [internal function]: Phalcon\Db\Adapter\Pdo->connect(Array) #2 /web/phalcon7/public/index.php(15): Phalcon\Db\Adapter\Pdo->__construct(Array) #3 {main} thrown in /web/phalcon7/public/index.php on line 15