Config
class Config extends Singleton (View source)
Manages configuration options for ActiveRecord.
ActiveRecord::initialize(function($cfg) {
$cfg->set_model_home('models');
$cfg->set_connections(array(
'development' => 'mysql://user:pass@development.com/awesome_development',
'production' => 'mysql://user:pass@production.com/awesome_production'));
});
Methods
Similar to a get_called_class() for a child class to invoke.
Sets the list of database connection strings.
Returns the connection strings array.
Returns a connection string if found otherwise null.
Returns the default connection string or null if there is none.
Returns the name of the default connection.
Set the name of the default connection.
Sets the directory where models are located.
Returns the model directory.
Turn on/off logging
Sets the logger object for future SQL logging
Return whether or not logging is on
Returns the logger
No description
No description
Sets the url for the cache server to enable query caching.
Details
final static object
instance()
Static method for instantiating a singleton object.
final protected string
get_called_class()
Similar to a get_called_class() for a child class to invoke.
at line 115
static void
initialize(Closure $initializer)
Allows config initialization using a closure.
This method is just syntatic sugar.
ActiveRecord\Config::initialize(function($cfg) {
$cfg->set_model_directory('/path/to/your/model_directory');
$cfg->set_connections(array(
'development' => 'mysql://username:password@127.0.0.1/database_name'));
});
You can also initialize by grabbing the singleton object:
$cfg = ActiveRecord\Config::instance();
$cfg->set_model_directory('/path/to/your/model_directory');
$cfg->set_connections(array('development' =>
'mysql://username:password@localhost/database_name'));
at line 133
void
set_connections(array $connections, string $default_connection = null)
Sets the list of database connection strings.
$config->set_connections(array(
'development' => 'mysql://username:password@127.0.0.1/database_name'));
at line 149
array
get_connections()
Returns the connection strings array.
at line 160
string
get_connection(string $name)
Returns a connection string if found otherwise null.
at line 173
string
get_default_connection_string()
Returns the default connection string or null if there is none.
at line 184
string
get_default_connection()
Returns the name of the default connection.
at line 195
void
set_default_connection(string $name)
Set the name of the default connection.
at line 206
void
set_model_directory(string $dir)
Sets the directory where models are located.
at line 217
string
get_model_directory()
Returns the model directory.
at line 231
void
set_logging(boolean $bool)
Turn on/off logging
at line 243
void
set_logger(object $logger)
Sets the logger object for future SQL logging
at line 258
boolean
get_logging()
Return whether or not logging is on
at line 268
object
get_logger()
Returns the logger
at line 273
set_date_class($date_class)
at line 290
get_date_class()
at line 298
get_date_format()
deprecated
deprecated
at line 307
set_date_format($format)
deprecated
deprecated
at line 329
set_cache(string $url, array $options = array())
Sets the url for the cache server to enable query caching.
Only table schema queries are cached at the moment. A general query cache will follow.
Example:
$config->set_cache("memcached://localhost");
$config->set_cache("memcached://localhost",array("expire" => 60));