D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
var
/
www
/
html
/
rosario
/
adm
/
app
/
adms
/
Models
/
helper
/
Filename :
AdmsRead.php
back
Copy
<?php namespace App\adms\Models\helper; use PDO; if (!defined('URL')) { header("Location: /"); exit(); } /** * Description of StsRead * * @copyright (c) year, Cesar Szpak - Celke */ class AdmsRead extends AdmsConn { private $Select; private $Values; private $Resultado; private $Query; private $Conn; function getResultado() { return $this->Resultado; } public function exeRead($Tabela, $Termos = null, $ParseString = null) { if (!empty($ParseString)) { parse_str($ParseString, $this->Values); } $this->Select = "SELECT * FROM {$Tabela} {$Termos}"; $this->exeInstrucao(); } public function fullRead($Query, $ParseString = null) { $this->Select = (string) $Query; if (!empty($ParseString)) { parse_str($ParseString, $this->Values); } //var_dump($this->Select); //var_dump($this->Values); $this->exeInstrucao(); } private function exeInstrucao() { $this->conexao(); try { $this->getIntrucao(); $this->Query->execute(); $this->Resultado = $this->Query->fetchAll(); } catch (Exception $ex) { $this->Resultado = null; } } private function conexao() { $this->Conn = parent::getConn(); $this->Query = $this->Conn->prepare($this->Select); $this->Query->setFetchMode(PDO::FETCH_ASSOC); } private function getIntrucao() { if ($this->Values) { foreach ($this->Values as $Link => $Valor) { if ($Link == 'limit' || $Link == 'offset') { $Valor = (int) $Valor; } $this->Query->bindValue(":{$Link}", $Valor, (is_int($Valor) ? PDO::PARAM_INT : PDO::PARAM_STR)); } } } }