protected function _get_datasource($ds_id) { $ds = Datasource_Section::load($ds_id); if ($ds === NULL) { throw HTTP_API_Exception::factory(API::ERROR_UNKNOWN, 'Datasource section not found'); } return $ds; }
/** * Получение списка заголовков документов * * @param integer $ds_id * @param array $ids * @return array */ public static function get_document_headers($ds_id, array $ids) { $result = array(); foreach ($ids as $i => $id) { if (isset(self::$_cached_headers[$ds_id][$id])) { $result[$id] = self::$_cached_headers[$ds_id][$id]; unset($ids[$i]); } } if (empty($ids)) { return $result; } $ds = Datasource_Section::load($ds_id); if (!$ds instanceof Datasource_Section) { return array(); } $db_result = DB::select('id', 'header')->from($ds->table())->where('id', 'in', $ids)->execute()->as_array('id', 'header'); foreach ($db_result as $id => $header) { self::$_cached_headers[$ds_id][$id] = $header; $result[$id] = $header; } return $result; }
/** * * @return array [$section, $docs, $fields, $count] */ public function fetch_data() { if (!$this->ds_id) { return array(); } list($docs, $fields) = $this->get_documents(); return array('section' => Datasource_Section::load($this->ds_id), 'docs' => $docs, 'fields' => $fields, 'count' => count($this->docs)); }
/** * Загрузка разедла по ID * * @param integer $id * @return null|Datasource_Section */ public static function load($id) { return Datasource_Section::load($id); }