i need initiate (next default one) database connection , want same way, yii configuration. i.e. feed configuration array:
array ( 'connectionstring'=>'mysql:host=localhost;dbname=dbname', 'charset'=>'utf8', 'username'=>'username', 'password'=>'password', 'emulateprepare'=>true )
and sure, all cdbconnection
's properties correctly set.
but, cdbconnection::__construct
accepts $dns
, $username
, $password
, nothing else.
the way, found far, initiate cdbconnection
empty values , iterate through configuration array keys , set each each:
$db = new cdbconnection(); foreach($config $key->$value) { $db->$key = $value; } $db->active = true;
but, have feeling, there should better way of doing this.
Comments
Post a Comment