50 lines
No EOL
960 B
PHP
50 lines
No EOL
960 B
PHP
<?php
|
|
|
|
/** Defino o local da classe */
|
|
namespace vendor\model;
|
|
|
|
class States
|
|
{
|
|
|
|
/** Variaveis da classe */
|
|
private $connection = null;
|
|
private $sql = null;
|
|
private $stmt = null;
|
|
|
|
/** Construtor da classe */
|
|
public function __construct()
|
|
{
|
|
|
|
/** Instanciamento da classe */
|
|
$this->connection = new MySql();
|
|
|
|
}
|
|
|
|
/** Listagem de todos os registros */
|
|
public function all()
|
|
{
|
|
|
|
/** Montagem do SQL */
|
|
$this->sql = 'SELECT * FROM states ORDER BY name ASC';
|
|
|
|
/** Preparo o SQL para execução */
|
|
$this->stmt = $this->connection->connect()->prepare($this->sql);
|
|
|
|
/** Executo o SQL */
|
|
$this->stmt->execute();
|
|
|
|
/** Retorno o resultado */
|
|
return $this->stmt->fetchAll(\PDO::FETCH_OBJ);
|
|
|
|
}
|
|
|
|
/** Destrutor da classe */
|
|
public function __destruct()
|
|
{
|
|
|
|
/** Instanciamento da classe */
|
|
$this->connection = null;
|
|
|
|
}
|
|
|
|
} |