コード例 #1
0
 /**
  * 打开 session
  *
  * @param string $savePath
  * @param string $sessionName
  *
  * @return boolean
  */
 function sessionOpen($savePath, $sessionName)
 {
     $dsnName = FLEA::getAppInf('sessionDbDSN');
     $dsn = FLEA::getAppInf($dsnName);
     $this->dbo =& FLEA::getDBO($dsn);
     if (!$this->dbo) {
         return false;
     }
     if (!empty($this->dbo->dsn['prefix'])) {
         $this->tableName = $this->dbo->dsn['prefix'] . $this->tableName;
     }
     $this->tableName = $this->dbo->qtable($this->tableName);
     $this->fieldId = $this->dbo->qfield($this->fieldId);
     $this->fieldData = $this->dbo->qfield($this->fieldData);
     $this->fieldActivity = $this->dbo->qfield($this->fieldActivity);
     $this->sessionGc(FLEA::getAppInf('sessionDbLifeTime'));
     return true;
 }
コード例 #2
0
 /**
  * 设置数据库访问对象
  *
  * @param FLEA_Db_Driver_Abstract $dbo
  *
  * @return boolean
  */
 function setDBO(&$dbo)
 {
     $this->dbo =& $dbo;
     if (empty($this->schema) && !empty($dbo->dsn['schema'])) {
         $this->schema = $dbo->dsn['schema'];
     }
     if (empty($this->fullTableName)) {
         $this->fullTableName = $dbo->dsn['prefix'] . $this->tableName;
     }
     $this->qtableName = $dbo->qtable($this->fullTableName, $this->schema);
     if (!$this->_prepareMeta()) {
         return false;
     }
     $this->fields = array_keys($this->meta);
     if (is_array($this->validateRules)) {
         foreach ($this->validateRules as $fieldName => $rules) {
             $fieldName = strtoupper($fieldName);
             if (!isset($this->meta[$fieldName])) {
                 continue;
             }
             foreach ((array) $rules as $ruleName => $rule) {
                 $this->meta[$fieldName][$ruleName] = $rule;
             }
         }
     }
     // 如果没有指定主键,则尝试自动获取
     if (empty($this->primaryKey)) {
         foreach ($this->meta as $field) {
             if ($field['primaryKey']) {
                 $this->primaryKey = $field['name'];
                 break;
             }
         }
     }
     if (is_array($this->primaryKey)) {
         $this->qpk = array();
         $this->pka = array();
         $this->qpka = array();
         foreach ($this->primaryKey as $pk) {
             $qpk = $dbo->qfield($pk, $this->fullTableName, $this->schema);
             $this->qpk[$pk] = $qpk;
             $pka = 'flea_pkref_' . $pk;
             $this->pka[$pk] = $pka;
             $this->qpka[$pk] = $qpk . ' AS ' . $pka;
         }
     } else {
         $this->qpk = $dbo->qfield($this->primaryKey, $this->fullTableName, $this->schema);
         $this->pka = 'flea_pkref_' . $this->primaryKey;
         $this->qpka = $this->qpk . ' AS ' . $this->pka;
     }
     return true;
 }