Guest User

Untitled

a guest
Oct 12th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. <?php
  2. // A way to doing a PDORepository
  3. abstract class PDORepository{
  4. const USERNAME="root";
  5. const PASSWORD="";
  6. const HOST="localhost";
  7. const DB="parcial";
  8.  
  9. private function getConnection(){
  10. $username = self::USERNAME;
  11. $password = self::PASSWORD;
  12. $host = self::HOST;
  13. $db = self::DB;
  14. $connection = new PDO("mysql:dbname=$db;host=$host", $username, $password);
  15. return $connection;
  16. }
  17. protected function queryList($sql, $args){
  18. $connection = $this->getConnection();
  19. $stmt = $connection->prepare($sql);
  20. $stmt->execute($args);
  21. return $stmt;
  22. }
  23. }
  24.  
  25. ?>
Add Comment
Please, Sign In to add comment