Skip to content

Instantly share code, notes, and snippets.

@erikfig
Created July 14, 2015 16:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erikfig/c26d81d4be3c3083911a to your computer and use it in GitHub Desktop.
Save erikfig/c26d81d4be3c3083911a to your computer and use it in GitHub Desktop.
<?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