Your app/config/database.php
file is where your database configuration all takes place. A fresh install doesn't have a database.php
, so you'll need to make a copy of database.php.default
. Once you've made a copy and renamed it you'll see the following:
Example 4.1. app/config/database.php
var $default = array('driver' => 'mysql', 'connect' => 'mysql_pconnect', 'host' => 'localhost', 'login' => 'user', 'password' => 'password', 'database' => 'project_name' );
Replace the information provided by default with the database connection information for your application.
Cakephp supports the following database drivers:
mysql |
postgres |
sqlite |
pear-drivername (so you might enter pear-mysql, for example) |
adodb-drivername |
The connect key in the $default connection allows you to specify whether or not the database connection will be treated as persistent or not. Read the comments in the database.php.default file for help on specifying connection types for your database setup.
Your database tables should also follow the following conventions:
Table names used by cake should consist of English words in plural, like "users", "authors" or "articles". Note that corresponding models have singular names.
Your tables must have a primary_key named 'id'.
If you plan to relate tables, use foreign keys that look like: 'article_id'. The table name is singular, followed by an underscore, followed by 'id'.
Additionally, you may adhere to the following conventions in order to take advantage of some free functionality:
Include a 'created' column
Include a 'modified' column
You'll also notice that there is also a $test connection setting included in the database.php file. Fill out this configuration (or add other similarly formatted configurations) and use it in your application by placing something like:
var $useDbConfig = 'test';
Inside one of your models.