Answer the question
In order to leave comments, you need to log in
How to connect a database in phalcon?
How to connect correctly?
on the off site it is somehow not clearly written, I did so, but the message SQLSTATE[HY000] is not displayed, but just a white screen.
What's wrong?
In module.php file
$di->set('db', function() use ($config) {
return new Phalcon\Db\Adapter\Pdo\Mysql(array(
'host' => $config->database->host,
'username' => $config->database->username,
'password' => $config->database->password,
'dbname' => $config->database->dbname,
'port' => $config->database->port,
'prefix' => $config->database->prefix,
'charset' => $config->database->charset
));
});
<?php
return new \Phalcon\Config(array(
'database' => array(
'adapter' => 'Mysql',
'host' => 'localhost',
'username' => 'root',
'password' => 'root',
'dbname' => 'blog',
'port' => '3306',
'charset' => 'utf8',
)
));
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question