Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Conexao {
- public $conn;
- function Conexao() {
- $string = "mysql:";
- $string .= "host=localhost ";
- $string .= "port=5432 ";
- $string .= "dbname=nomedobanco";
- $string .= "user=usuario";
- $string .= "password=senha";
- try {
- $this->conn = new PDO($string);
- }catch(PDOException $e){
- echo $e->getMessage();
- }
- }
- }
- ?>
- new PDO('mysql:host=localhost;dbname=testdb;charset=utf8mb4', 'username', 'password');
- <?php
- require('class.conexao.php');
- class Querys extends Conexao {
- function validaLogin($login, $senha) {
- $sql =
- "
- select nome, cpf from validaUsuario('".$login."', '".$senha."');
- ";
- $stmt = $this->conn->prepare($sql);
- $stmt->execute();
- $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
- return $result;
- }
- }
- $stmt = $this->conn->prepare($sql);
- $stmt->execute();
- $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
- return $result;
- <?php
- require_once('class.querys.php');
- class Editora extends Querys {
- function listaEditora() {
- $query = new Querys();
- $retorno = $query->validaLogin(aqui vem os parametros));
- return $retorno;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement