S
S
s_katala2017-07-13 17:47:37
PHP
s_katala, 2017-07-13 17:47:37

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
      ));
        });

In config.php file
<?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

1 answer(s)
E
Evgeny Matveev, 2021-02-28
@ematveev

look at the error log

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question