O'Reilly logo

Learning Phalcon PHP by Calin Rada

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Connecting to the database

In the previous chapter, we added a global configuration file and configuration files per module. In order to be able to connect to a database, we need to add some lines to our configuration file first.

Let's recall our directory structure:

Connecting to the database

In order to connect to a database, we need to create it. Create a database named learning_phalcon. You can do this quickly with the help of the following command line:

$ mysql -u YOURUSERNAME -p -e 'create database learning_phalcon;'

Open the global configuration file (config/config.php), and add these lines:

 'database' => array( 'adapter' => 'Mysql', 'host' => 'localhost', 'username' ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required