Advertisement
Guest User

Untitled

a guest
Nov 15th, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. <?php
  2. class Conexao {
  3. public $conn;
  4. function Conexao() {
  5. $string = "mysql:";
  6. $string .= "host=localhost ";
  7. $string .= "port=5432 ";
  8. $string .= "dbname=nomedobanco";
  9. $string .= "user=usuario";
  10. $string .= "password=senha";
  11.  
  12. try {
  13. $this->conn = new PDO($string);
  14. }catch(PDOException $e){
  15. echo $e->getMessage();
  16. }
  17.  
  18. }
  19.  
  20. }
  21.  
  22.  
  23.  
  24.  
  25.  
  26. ?>
  27.  
  28. new PDO('mysql:host=localhost;dbname=testdb;charset=utf8mb4', 'username', 'password');
  29.  
  30. <?php
  31.  
  32. require('class.conexao.php');
  33.  
  34. class Querys extends Conexao {
  35.  
  36.  
  37. function validaLogin($login, $senha) {
  38.  
  39. $sql =
  40. "
  41. select nome, cpf from validaUsuario('".$login."', '".$senha."');
  42. ";
  43.  
  44. $stmt = $this->conn->prepare($sql);
  45. $stmt->execute();
  46. $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
  47. return $result;
  48.  
  49. }
  50.  
  51.  
  52. }
  53.  
  54. $stmt = $this->conn->prepare($sql);
  55. $stmt->execute();
  56. $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
  57. return $result;
  58.  
  59. <?php
  60. require_once('class.querys.php');
  61.  
  62. class Editora extends Querys {
  63.  
  64. function listaEditora() {
  65.  
  66. $query = new Querys();
  67.  
  68. $retorno = $query->validaLogin(aqui vem os parametros));
  69.  
  70. return $retorno;
  71. }
  72. }
  73.  
  74. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement