@@ -48,26 +48,47 @@ Of course, there are some differences which will be obvious to the user if they
48
48
49
49
### Installation ##
50
50
51
- Setup is very easy and straight-forward. There are essentially only two configuration points you must concern yourself with:
51
+ Setup is very easy and straight-forward. There are essentially only three configuration points you must concern yourself with:
52
52
53
53
1 . Setting the model auto_load directory.
54
54
2 . Configuring your database connections.
55
+ 3 . Setting the database connection to use for your environment.
55
56
56
57
Example:
57
58
58
59
ActiveRecord\Config::initialize(function($cfg)
59
60
{
60
61
$cfg->set_model_directory('/path/to/your/model_directory');
61
- $cfg->set_connections(array('development' => 'mysql://username:password@localhost/database_name'));
62
+ $cfg->set_connections(
63
+ array(
64
+ 'development' => 'mysql://username:password@localhost/development_database_name',
65
+ 'test' => 'mysql://username:password@localhost/test_database_name',
66
+ 'production' => 'mysql://username:password@localhost/production_database_name'
67
+ )
68
+ );
62
69
});
63
70
64
71
Alternatively (w/o the 5.3 closure):
65
72
66
73
$cfg = ActiveRecord\Config::instance();
67
74
$cfg->set_model_directory('/path/to/your/model_directory');
68
- $cfg->set_connections(array('development' => 'mysql://username:password@localhost/database_name'));
75
+ $cfg->set_connections(
76
+ array(
77
+ 'development' => 'mysql://username:password@localhost/development_database_name',
78
+ 'test' => 'mysql://username:password@localhost/test_database_name',
79
+ 'production' => 'mysql://username:password@localhost/production_database_name'
80
+ )
81
+ );
82
+
83
+ PHP ActiveRecord will default to use your development database. For testing or production, you simply set the default
84
+ connection according to your current environment ('test' or 'production'):
85
+
86
+ ActiveRecord\Config::initialize(function($cfg)
87
+ {
88
+ $cfg->set_default_connection(your_environment);
89
+ });
69
90
70
- Once you have configured these two settings you are done. ActiveRecord takes care of the rest for you.
91
+ Once you have configured these three settings you are done. ActiveRecord takes care of the rest for you.
71
92
It does not require that you map your table schema to yaml/xml files. It will query the database for this information and
72
93
cache it so that it does not make multiple calls to the database for a single schema.
73
94
0 commit comments