在入口文件index.php中
$di = new Phalcon\DI\FactoryDefault();
//Setup the database service
$di->set('db', function(){
return new \Phalcon\Db\Adapter\Pdo\Mysql(array(
"host" => "192.168.18.109",
"username" => "xiaoshen",
"password" => "xiaoshen123",
"dbname" => "xiaoshenphalcon",
'options' => array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8')
));
});
主要注意下要记得设定编码方式,不然会乱码