Ir para conteúdo

Luan Agusto

Members
  • Total de itens

    2
  • Registro em

  • Última visita

Tudo que Luan Agusto postou

  1. Luan Agusto

    Retorno SELECT Orientado ao Objeto

    Gabriel, olha como esta a consulta do banco class Sql extends PDO { private $conn; public function __construct(){ $this->conn = new PDO("mysql:host=localhost;dbname=gests", "root", "" ); } private function setParams($statement, $parameters = array()){ foreach ($parameters as $key => $value) { $this->setParam($statement, $key, $value); } } private function setParam($statement, $key, $value){ $statement->bindParam($key, $value); } public function query($rawQuery, $params = array()){ $stmt = $this->conn->prepare($rawQuery); $this->setParams($stmt, $params); $stmt->execute(); return $stmt; } public function select($rawQuery, $params = array()):array{ $stmt = $this->query($rawQuery, $params); return $stmt->fetchAll(PDO::FETCH_ASSOC); } } ?>
  2. Luan Agusto

    Retorno SELECT Orientado ao Objeto

    Estou querendo percorrer uma return de Um select, mas quando o return e maior que um, ele retorna uma erro, as variaveis ficam nulas. alguém pode me ajudar ? class Extracao { private $codblo; private $codpro; private $zonsts; private $allsts; private $dplsts; private $nivsts; private $ds1pro; private $pcbpro; private $etapal; private $uvcsto; private $datrec; private $datfvi; private $uvcdes; public function getCodblo(){ return $this->codblo; } public function setCodblo($codblo){ $this->codblo = $codblo; } public function getCodpro(){ return $this->codpro; } public function setCodpro($codpro){ $this->codpro = $codpro; } public function getZonsts(){ return $this->zonsts; } public function setZonsts($zonsts){ $this->zonsts = $zonsts; } public function getAllsts(){ return $this->allsts; } public function setAllsts($allsts){ $this->allsts = $allsts; } public function getDplsts(){ return $this->dplsts; } public function setDplsts($dplsts){ $this->dplsts = $dplsts; } public function getNivsts(){ return $this->nivsts; } public function setNivsts($nivsts){ $this->nivsts = $nivsts; } public function getDs1pro(){ return $this->ds1pro; } public function setDs1pro($ds1pro){ $this->ds1pro = $ds1pro; } public function getPcbpro(){ return $this->pcbpro; } public function setPcbpro($pcbpro){ $this->pcbpro = $pcbpro; } public function getEtapal(){ return $this->etapal; } public function setEtapal($etapal){ $this->Etapal = $etapal; } public function getUvcsto(){ return $this->uvcsto; } public function setUvcsto($uvcsto){ $this->uvcsto = $uvcsto; } public function getDatrec(){ return $this->datrec; } public function setDatrec($datrec){ $this->daterec = $datrec; } public function getDatfvi(){ return $this->datfvi; } public function setDatfvi($datfvi){ $this->datfvi = $datfvi; } public function getUvcdes(){ return $this->uvcdes; } public function setuvcdes($uvcdes){ $this->uvcdes = $uvcdes; } public function setData($data){ $this->setCodblo($data['CODBLO']); $this->setCodpro($data['CODPRO']); $this->setZonsts($data['ZONSTS']); $this->setAllsts($data['ALLSTS']); $this->setDplsts($data['DPLSTS']); $this->setNivsts($data['NIVSTS']); $this->setDs1pro($data['DS1PRO']); $this->setPcbpro($data['PCBPRO']); $this->setEtapal($data['ETAPAL']); $this->setUvcsto($data['UVCSTO']); $this->setDatrec($data['DATREC']); $this->setDatfvi($data['DATFVI']); $this->setuvcdes($data['UVCDES']); } public function getList($codpro){ $list = new Sql(); $results = $list->select("SELECT gests.ZONSTS, gests.ALLSTS, gests.DPLSTS, gests.NIVSTS, gests.CODPRO, gepal.DS1PRO, gepal.PCBPRO, gepal.ETAPAL, gepal.DATREC, gepal.DATFVI, gepal.UVCSTO FROM gests LEFT JOIN gepal ON gests.CODPRO = gepal.CODPRO WHERE gests.CODPRO = :CODPRO", array( ":CODPRO"=>$codpro )); return $results; //var_dump($results); //if(count($results) > 0){ // $this->setData($results); //} } public function __toString(){ return json_encode(array( "CODBLO"=>$this->getCodblo(), "CODPRO"=>$this->getCodpro(), "ZONSTS"=>$this->getZonsts(), "ALLSTS"=>$this->getAllsts(), "DPLSTS"=>$this->getDplsts(), "NIVSTS"=>$this->getNivsts(), "DS1PRO"=>$this->getDs1pro(), "PCBPRO"=>$this->getPcbpro(), "ETAPAL"=>$this->getEtapal(), "UVCSTO"=>$this->getUvcsto(), "DATREC"=>$this->getDatrec(), "DATFVI"=>$this->getDatfvi(), "UVCDES"=>$this->getUvcdes() )); } } ?> // index.php <?php require_once 'config.php'; /* $sql = new Sql(); $results = $sql->select("SELECT *FROM gests"); echo json_encode($results); */ $conn = new Extracao(); $conn->getList("7896290300011"); //echo $conn; ?>
×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.