retesere20

--pdo-alternative

Feb 17th, 2019
196
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. // Conenction creator
  3. public static function create_connection_($db_name){
  4. try {
  5. $db = new PDO('sqlite:'.__DIR__.'/databases/'.$db_name);
  6. $db ->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  7. //$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  8. } catch(Exception $e) {
  9. echo 'Error: ';
  10. echo $e->getMessage();
  11. die();
  12. }
  13. return $db ;
  14. }
  15.  
  16.  
  17. private $pdo = null;
  18. public $lang = "";
  19. public $found = false;
  20. // user opts
  21. public $programName = "example";
  22. public $googleKey = "";
  23. public $isDeveloper = false;
  24.  
  25.  
  26. public function __construct($db_name="db_all.db") {
  27. $this->pdo = generic_funcs::create_connection_($db_name);
  28.  
  29. ///
  30. ...
  31. $statement->execute();
  32. $res = $statement->fetchAll(PDO::FETCH_ASSOC);
  33. }
RAW Paste Data