/** * Method to check existance of an item by ID * * @param int $contentId The id of the content to test if exists * * @return boolean True or false if the item exists or not in database * * @since 1.0 * @throws InvalidArgumentException * @throws RuntimeException * @throws UnexpectedValueException */ public function existsItem($contentId) { // Build the query object. $query = $this->db->getQuery(true); $query->select('COUNT(' . $query->qn('a.content_id') . ')'); $query->from($query->qn('#__content', 'a')); $query->innerJoin($query->qn('#__content_types', 'b') . ' ON ' . $query->qn('b.type_id') . ' = ' . $query->qn('a.type_id')); $query->where($query->qn('a.content_id') . ' = ' . (int) $contentId); // Check if we should filter the list based on content type. if (!is_null($this->state->get('content.type'))) { // Get the requested type. $type = $this->state->get('content.type'); // The type can be either a string type alias or a numeric type id. if (is_numeric($type)) { // Handle a numeric type. $query->where($query->qn('a.type_id') . ' = ' . (int) $type); } elseif (is_string($type)) { // Handle a type alias. $query->where($query->qn('b.alias') . ' = ' . $query->q($type)); } } $this->db->setQuery($query); $row = $this->db->loadRow(); if ((int) $row[0] > 0) { return true; } else { return false; } }
/** * @return \stdClass The first row of the query. * * @throws \RuntimeException */ public function loadRow() { return $this->_db->loadRow(); }