Skip to content

Commit

Permalink
setting attribute in PDO class
Browse files Browse the repository at this point in the history
  • Loading branch information
thalysontest committed Mar 14, 2018
1 parent 28d288a commit c267ff6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 19 deletions.
36 changes: 18 additions & 18 deletions app/Models/DAO/Tree.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,24 @@ public static function findOne($id) {

foreach ($query as $value) {
$object = new \app\Models\bean\Tree();
$object->setId( $value["id"]);
$object->setNomeComum( $value["nome_comum"]);
$object->setEspecie( $value["especie"]);
$object->setFamilia( $value["familia"]);
$object->setCap( $value["cap"]);
$object->setAlturaTotal( $value["altura_total"]);
$object->setClasseCopa( $value["classe_copa"]);
$object->setSanidade( $value["sanidade"]);
$object->setCrescimento( $value["crescimento"]);
$object->setPosSociologica( $value["pos_sociologica"]);
$object->setUtilizacao( $value["utilizacao"]);
$object->setCaracteristicas( $value["caracteristicas"]);
$object->setDataRegistro( $value["data_registro"]);
$object->setUsuarioNome( $value["usuario_nome"]);
$object->setUsuarioDescricao($value["usuario_descricao"]);
$object->setImgArvore( $value["img_arvore"]);
$object->setLatitude( $value["latitude"]);
$object->setLongitude( $value["longitude"]);
$object->setId( $value->id);
$object->setNomeComum( $value->nome_comum);
$object->setEspecie( $value->especie);
$object->setFamilia( $value->familia);
$object->setCap( $value->cap);
$object->setAlturaTotal( $value->altura_total);
$object->setClasseCopa( $value->classe_copa);
$object->setSanidade( $value->sanidade);
$object->setCrescimento( $value->crescimento);
$object->setPosSociologica( $value->pos_sociologica);
$object->setUtilizacao( $value->utilizacao);
$object->setCaracteristicas( $value->caracteristicas);
$object->setDataRegistro( $value->data_registro);
$object->setUsuarioNome( $value->usuario_nome);
$object->setUsuarioDescricao($value->usuario_descricao);
$object->setImgArvore( $value->img_arvore);
$object->setLatitude( $value->latitude);
$object->setLongitude( $value->longitude);
$tree[] = $object;
}
return $tree[0];
Expand Down
3 changes: 2 additions & 1 deletion app/classes/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class Database
private static function connect() {
$pdo = new \PDO(self::$database . ":host=" . self::$hostname . ";port=" . self::$port . ";dbname=" . self::$dbName . ";charset=" . self::$charset, self::$username, self::$password);
$pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
$pdo->setAttribute(\PDO::ATTR_DEFAULT_FETCH_MODE, \PDO::FETCH_OBJ);
return $pdo;
}

Expand All @@ -57,7 +58,7 @@ public static function query($query, $params = []) {
$statement->execute($params);

if (explode(' ', $query)[0] == 'SELECT') {
$data = $statement->fetchAll(\PDO::FETCH_ASSOC);
$data = $statement->fetchAll();
return $data;
}
}
Expand Down
Binary file modified public/assets/images/tmp/tree.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c267ff6

Please sign in to comment.