SHARE
TWEET

Untitled

a guest Mar 24th, 2019 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class DbConnection {
  2.  
  3.     private $connection;
  4.  
  5.     public function connect()
  6.     {
  7.           $this->connection = new PDO('mysql:host='.DB_SERVER.';dbname='.DB_NAME, DB_USER, DB_PASS, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
  8.           $this->connection->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
  9.     }
  10.  
  11.     public function query($query)
  12.     {
  13.         $result = $this->connection -> query($query);
  14.         while ($row = $result->fetch()) {
  15.             printf('<table><tr><td>%s</td><td>%s</td><td>%s</td></tr></table><br>',
  16.                 $row['id_ceginformacio'],
  17.                 $row['cegnev'],
  18.                 $row['vevokod']
  19.             );
  20.         }
  21.  
  22.         // ...
  23.     }
  24. }
  25.  
  26. $database = new DbConnection();
  27. $database->connect();
  28. $database->query("SELECT * FROM ".TBL_CEGINFORMACIO)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top