I am using this configuration:
$di->set('db', function () use ($config) { $connection = new \Phalcon\Db\Adapter\Pdo\Mysql(array( "host" => $config->database->host, "username" => $config->database->username, "password" => $config->database->password, "dbname" => $config->database->dbname, "options" => array( PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'UTF8'" ) )); if (APPLICATION_ENV == 'development') { $eventsManager = new Phalcon\Events\Manager(); $logger = new Phalcon\Logger\Adapter\File($config->application->logsDir . "sql_debug.log");
There is another parameter for utf8, and if the application environment is development, it logs all sql calls to sql_debug.log. You can see that I am using $ config, it is defined as follows:
switch (APPLICATION_ENV) { case 'development': $config = new Phalcon\Config\Adapter\Ini(__DIR__ . '/../app/config/config_dev.ini'); break; case 'testing': $config = new Phalcon\Config\Adapter\Ini(__DIR__ . '/../app/config/config_test.ini'); break; case 'production': $config = new Phalcon\Config\Adapter\Ini(__DIR__ . '/../app/config/config_production.ini'); break; }
and in the configuration file you will find something like this:
[database] adapter = Mysql host = localhost username = root password = dbname = db_name
source share