コード例 #1
0
ファイル: Session.php プロジェクト: dmitriz/Platform
 static function processDbInfo()
 {
     static $db_info = null;
     if ($db_info) {
         return $db_info;
     }
     if (!$db_info) {
         $db_info = Q_Config::get('Q', 'session', 'db', null);
     }
     if (!$db_info) {
         return null;
     }
     $session_db_connection = isset($db_info['connection']) ? $db_info['connection'] : null;
     // use the DB for session
     $session_db_data_field = isset($db_info['dataField']) ? $db_info['dataField'] : null;
     if (empty($session_db_data_field)) {
         throw new Q_Exception_WrongType(array('field' => 'session_db_data_field', 'type' => 'string'));
     }
     $session_db_id_field = isset($db_info['idField']) ? $db_info['idField'] : null;
     if (empty($session_db_id_field)) {
         throw new Q_Exception_WrongType(array('field' => 'session_db_id_field', 'type' => 'string'));
     }
     $session_db_updated_field = isset($db_info['updatedField']) ? $db_info['updatedField'] : null;
     if (empty($session_db_updated_field)) {
         throw new Q_Exception_WrongType(array('field' => 'session_db_updated_field', 'type' => 'string'));
     }
     $session_db_duration_field = isset($db_info['durationField']) ? $db_info['durationField'] : null;
     if (empty($session_db_duration_field)) {
         throw new Q_Exception_WrongType(array('field' => 'session_db_duration_field', 'type' => 'string'));
     }
     $session_db_row_class = isset($db_info['rowClass']) ? $db_info['rowClass'] : null;
     if (empty($session_db_row_class) or !class_exists($session_db_row_class)) {
         throw new Q_Exception_WrongType(array('field' => 'session_db_row_class', 'type' => 'a class name'));
     }
     $session_db_table = call_user_func(array($session_db_row_class, 'table'));
     $class = $session_db_row_class;
     $ancestors = array($class);
     while ($class = get_parent_class($class)) {
         $ancestors[] = $class;
     }
     if (!in_array('Db_Row', $ancestors)) {
         throw new Q_Exception_WrongType(array('field' => 'session_db_row_class', 'type' => 'name of a class that extends Db_Row'));
     }
     self::$session_db_connection = $session_db_connection;
     self::$session_db_table = $session_db_table;
     self::$session_db_data_field = $session_db_data_field;
     self::$session_db_id_field = $session_db_id_field;
     self::$session_db_updated_field = $session_db_updated_field;
     self::$session_db_duration_field = $session_db_duration_field;
     self::$session_db_row_class = $session_db_row_class;
     self::$session_db = Db::connect(self::$session_db_connection);
     return $db_info;
 }