/** * read * * @param string|int $id * * @return string */ public function read($id) { // Get the session data from the database table. $query = $this->db->getQuery(true); $query->select($this->db->quoteName($this->options['data_col']))->from($this->db->quoteName($this->options['table']))->where($this->db->quoteName($this->options['id_col']) . ' = ' . $this->db->quote($id)); $this->db->setQuery($query); return (string) $this->db->loadResult(); }
/** * Validate that the primary key has been set. * * @return boolean True if the primary key(s) have been set. * * @since 2.0 */ public function hasPrimaryKey() { if ($this->autoIncrement) { $empty = true; foreach ($this->keys as $key) { $empty = $empty && !$this->{$key}; } } else { $query = $this->db->getQuery(true); $query->select('COUNT(*)')->from($this->table); $this->appendPrimaryKeys($query); $this->db->setQuery($query); $count = $this->db->loadResult(); if ($count == 1) { $empty = false; } else { $empty = true; } } return !$empty; }