public function load($cid) { static $instances = array(); if (empty($cid)) { return NULL; } if (!isset($instances[$cid])) { // Check if this record exist or not $sql = Komento::getSql(); $sql->select('#__js_res_record')->column('id', 'id', 'count')->where('id', $cid); $result = $sql->loadResult(); if ($result < 1) { return $this->onLoadArticleError($cid); } $item = ItemsStore::getRecord($cid); $item->url = $this->prepareLink(Url::record($item)); $instances[$cid] = $item; } $this->_item = $instances[$cid]; return $this; }
public static function getSectionRecords($params) { $db = JFactory::getDbo(); $items = null; $sql = $db->getQuery(true); $sql->select('id'); $sql->from('#__js_res_record'); $sql->where('published = 1'); $sql->where('hidden = 0'); $sql->where('section_id = ' . $params->get('section_id')); $sql->where("ctime < " . $db->quote(JFactory::getDate()->toSql())); $sql->where("(extime = '0000-00-00 00:00:00' OR extime > '" . JFactory::getDate()->toSql() . "')"); $sql->where("id NOT IN (SELECT record_id FROM #__js_res_record_category WHERE section_id = '" . $params->get('section_id') . "')"); $db->setQuery($sql, 0, $params->get('records_limit') ? $params->get('records_limit') + 1 : 0); if ($recs = $db->loadColumn()) { $items = array(); foreach ($recs as $rid) { $record = ItemsStore::getRecord($rid); $record->url = Url::record($record); $items[] = $record; } } return $items; }