public function getSocket($type = 'read') { $type = in_array($type, array('read', 'write')) ? $type : 'read'; if (is_null($this->_hs[$type])) { $config = $this->_config; if (!is_array($config)) { throw new Pix_Exception('config error'); } $hs = new HandlerSocket($config[$type]['host'], $config[$type]['port']); if ('write' == $type) { if (!$hs->openIndex(1, $config[$type]['dbname'], $config[$type]['table'], '', 'value')) { throw new Exception($hs->getError()); } } else { if (!$hs->openIndex(1, $config[$type]['dbname'], $config[$type]['table'], HandlerSocket::PRIMARY, 'key,value')) { throw new Exception($hs->getError()); } } $this->_hs[$type] = $hs; } return $this->_hs[$type]; }
/** * Внутренняя реализация открытия индекса. * * @param HandlerSocket $driver Драйвер через который должен быть открыт индекс. * @param int $indexId Идентификатор индекса. * @param string $tableName Имя таблицы в БД, с которой ассоциирован индекс. * @param string $indexName Имя индекса в БД. * @param array $fields Список полей, которые должны быть доступны через индекс. * @param array $filter Фильтр индекса. * @return bool Результат выполнения операции. */ protected function _openIndex($driver, $indexId, $tableName, $indexName, $fields, $filter) { return (bool) $driver->openIndex($indexId, $this->_database, $tableName, $indexName, $fields, $filter); }