Advertisement
kura2yamato

controller pdo

Apr 27th, 2022
1,049
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. error_reporting(0);
  3. /*** ketik problem anda dibawah ini
  4. mengeluarkan sesuai controller
  5. */
  6. /* ketik coding PHP anda dibawah ini */
  7.  
  8. class Db
  9. {
  10.     private $dbSetup;
  11.     private $conn;
  12.     private $que;
  13.     function __construct($param)
  14.     {
  15.         $this->dbSetup = $param;
  16.     }
  17.    
  18.     function db()
  19.     {
  20.         $this->conn = new PDO($dsn, $user, $password);
  21.     }
  22.    
  23.     function beginTransaction(){
  24.         $this->conn->beginTransaction();
  25.     }
  26.    
  27.     function countRegisteration($data)
  28.     {
  29.         $email = $data['email'];
  30.         $que = $this->conn->prepare("select count(*) from table where email=?");
  31.         $que->bindValue(1, $email);
  32.        
  33.         $this->que = $que;
  34.     }
  35.    
  36.     function st()
  37.     {
  38.         $this->que->execute();
  39.     }
  40.    
  41.     function fetchColumn()
  42.     {
  43.         return $this->que->fetchColumn();
  44.     }
  45. }
  46.  
  47.  
  48. /* end of file */
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement