Advertisement
Guest User

Untitled

a guest
Oct 20th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.70 KB | None | 0 0
  1. <?php
  2. class DBCLASS
  3. {
  4.     function Connect()
  5.     {
  6.  
  7.         try
  8.         {
  9.  
  10.             $connect = new PDO("mysql:host=localhost;dbname=OOP", "root", "");
  11.             $connect->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  12.         }
  13.  
  14.         catch(PDOException  $e ){
  15.             echo "Connect Error: <p style='color: red'> " . $e ."</p>";
  16.         }
  17.  
  18.     }
  19.  
  20.  
  21. public function getData($db, $query, $parm = [])
  22. {
  23.     $stmt = $db->prepare($query);
  24.     $stmt->execute($parm);
  25.     $rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
  26.     return $rows;
  27. }
  28. public function setData($db, $query, $parm = [])
  29. {
  30.     $stmt = $db->prepare($query);
  31.     $stmt->execute($parm);
  32.     $count = $stmt->rowCount();
  33.     return $count;
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement