/** * Retorna um unico registro por PKs. * * @return array * @throws \Exception */ public function get() { $this->checkGateway(); $id = func_get_args(); // Monta query $sql = "SELECT * FROM " . $this->name . " WHERE "; foreach ((array) $this->primary as $key => $primary) { // Mais chaves primarias que parametros no metodo if (!isset($id[$key])) { throw new \Exception("O método 'get' só funciona passando TODAS as chaves primárias de uma vez"); } // Parametro na query $sql .= $primary . " = :" . $primary . " AND "; // Parametro, query segura $this->db->bind($primary, $id[$key]); } $sql = trim($sql, " AND "); // Resultado return $this->db->row($sql); }