Advertisement
Guest User

Untitled

a guest
Apr 19th, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. <?php
  2.  
  3. $host = 'localhost';
  4. $dbname = 'test';
  5. $charset = 'utf8';
  6.  
  7. $dbuser = 'root';
  8. $dbpassword = '';
  9.  
  10. $opt = array(
  11. PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
  12. PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC
  13. );
  14.  
  15. $dsn = "mysql:host = $host; dbname = $dbname; charset = $charset";
  16.  
  17. $pdo = new PDO($dsn, $dbuser, $dbpassword, $opt);
  18.  
  19. <?php
  20.  
  21. function getAllWorkers() {
  22. $stmt = $pdo->query('SELECT * FROM `workers`');
  23.  
  24. while($row = $stmt->fetch()) {
  25. echo $row['name'];
  26. }
  27. }
  28.  
  29. <?php
  30.  
  31. function getAllWorkers() {
  32. global $pdo;
  33. ...
  34.  
  35. <?php
  36.  
  37. require_once '../config/config.php';
  38. require_once '../libs/Functions.php';
  39. require_once '../config/db.php';
  40.  
  41. $controllerName = isset($_GET['controller']) ? ucfirst($_GET['controller']) : 'Index';
  42. $actionName = isset($_GET['action']) ? $_GET['action'] : 'index';
  43.  
  44. loadPage($twig, $controllerName, $actionName);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement