Esempio n. 1
0
 protected static function connectModel($model, $host)
 {
     // cached handle is not null
     // and new host is null
     // use cached
     if (self::$db_handle !== null && $host === null) {
         $model->setDBH(self::$db_handle);
     } elseif ($host !== null) {
         // use a new host
         $dbh = DBPool::getConnection($host);
         $model->setDBH($dbh);
     } elseif (self::$db_handle == null && $host == null) {
         // db_handle is null and host is null
         // (initiate default)
         $handle = DBPool::getDefCX();
         $model->setDBH($handle);
         self::$db_handle = $handle;
     }
 }