/** * Fetches all entries, if parameter = null, otherwise all from the given * array like array(1, 2, 3) * * @param array $ids Array of IDs * * @return array * @throws PMF_Exception */ public function fetchAll(array $ids = null) { $ratings = array(); $query = sprintf("\n SELECT\n id,\n artikel as record_id,\n vote as sumVotings,\n usr as numVotings,\n datum as date,\n ip\n FROM\n %sfaqvoting\n WHERE\n 1=1", SQLPREFIX); if (!is_null($ids)) { $query .= sprintf("\n AND \n id IN (%s)", implode(', ', $ids)); } $result = $this->db->query($query); if (!$result) { throw new PMF_Exception($this->db->error()); } else { $ratings = $this->db->fetchAll($result); } return $ratings; }