values parse_str($parseString, $this->values); } // Montando a SQL para busca em BD $this->select = "SELECT * FROM {$tabela} {$termos}"; $this->executarInstrucao(); } private function getInstrucao(){ if ($this->values) { foreach ($this->values as $link => $valor) { if ($link == 'limit' || $link == 'offset') { $valor = (int)$valor; } // garantido a integridade dos valores passados (bindvalue) $this->query->bindValue(":{$link}", $valor, (is_int($valor) ? PDO::PARAM_INT : PDO::PARAM_STR)); } } } private function executarInstrucao(){ $this->conexao(); try{ // associando os atributos aos identificadores para a SQL $this->getInstrucao(); $this->query->execute(); // traz todas as linhas do registro $this->result = $this->query->fetchAll(); }catch (PDOException $e){ $this->result = null; $this->msg = "Erro ao Ler dados: {$e->getMessage()}"; } } private function conexao(){ // chamando o método da classe pai $this->conn = parent::getConn(); // preparando a SQL $this->query = $this->conn->prepare($this->select); // colocando o modo de exibição da query como ASSOCIAÇÃO (nome dos campos) $this->query->setFetchMode(PDO::FETCH_ASSOC); } // GETTERS IMPORTANTES PARA ACESSO EXTERNO public function getResult(){ return $this->result; } public function getMsg(){ return $this->msg; } public function getRowCount() { return $this->query->rowCount(); } }