/** * Initialize device for using with ObjectFs * * Throws: none * * @param devId int Device-ID * @return void */ public function devInit($devId) { if (!($res = $this->_dbh->query("SELECT mount_path FROM {$this->_devTable} WHERE id=?", $devId)->fetchAll())) { throw new RM_Base_Exception_Internal("Device #{$devId} not found"); } if (!file_exists($mp = $res[0]['mount_path'])) { throw new RM_Base_Exception_Internal("Device mount point `{$res[0]['mount_path']}' not exists"); } $this->_devDirCreate($mp, $this->_devDepth); }
public function &_getPermData($accessId) { if (!isset($this->_permData[$accessId])) { if (!$this->_cacheNs or !($data = M('Cache')->get($this->_cacheNs, $accessId))) { $res = $this->_dbh->query("SELECT pd_data FROM {$this->_pdTable} WHERE pd_access_id = ?", $accessId)->fetchAll(); $data = isset($res[0]) ? $res[0]['pd_data'] : ''; if ($data and $this->_cacheNs) { M('Cache')->put($this->_cacheNs, $accessId, $data); } } $this->_permData[$accessId] = $data ? M('Extensions')->binaryToList($data, $this->_listFmt) : array(); } return $this->_permData[$accessId]; }
/** * Retrievs object by key * * @param keyName string Key name * @param keyValue mixed Key value * @param factory RM_Store_iFactory Allow to override default storage factory (Default is NULL) * @return RM_Store_Object | NULL */ public function loadObjectByKey($keyName, $keyValue, RM_Store_iFactory $factory = NULL) { if ($object = $this->_mediator->identityMap->lookup($keyName, $keyValue)) { return $object; } if ($this->_cacheNs and $row = $this->cacheLookup($keyName, $keyValue)) { return $this->_mediator->factory->create($row); } $props = $this->_mediator->meta->keyProps($keyName, $keyValue); if (!isset($this->_loadByKeySth[$keyName])) { foreach ($props as $p => $v) { $where[] = $this->_mediator->meta->dbQuoted($p) . ' = ?'; } $this->_loadByKeySth[$keyName] = "SELECT " . join(',', $this->_mediator->meta->dbQuotedList()) . " FROM {$this->_table} WHERE " . join(' AND ', $where); } if (!count($rows = $this->_dbh->query($this->_loadByKeySth[$keyName], array_values($props))->fetchAll())) { return M('Base')->null(); } $object = $this->_mediator->factory->create($rows[0]); if ($this->_cacheNs) { $this->cacheUpdate($object, $rows[0]); } return $object; }