Created
July 14, 2015 16:00
-
-
Save erikfig/c26d81d4be3c3083911a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Core\BancoDeDados; | |
class BancoDeDados | |
{ | |
private $config, $pdo; | |
public function __construct(Array $config) | |
{ | |
$this->config = $config; | |
} | |
public function conecta() | |
{ | |
$this->pdo = new \PDO( | |
'mysql:host='.$this->config['servidor'].'dbname='.$this->config['banco'], | |
$this->config['usuario'], | |
$this->config['senha'], | |
$this->config['options'] | |
); | |
echo 'mysql:host='.$this->config['servidor'].'dbname='.$this->config['banco'];exit; | |
return $this->pdo; | |
} | |
public function executa() | |
{ | |
$select = $this->pdo->prepare('SELECT * FROM usuarios WHERE nome = :nome;'); | |
$select->bindValue(':nome', $_GET['nome']); | |
$select->execute(); | |
return $select->fetchAll(\PDO::FETCH_ASSOC); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment