SHARE
TWEET

Untitled

a guest Oct 3rd, 2017 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. #October 3, 2017
  3.  
  4. #First activate pdo_odbc in your server
  5. #extension=php_pdo_odbc.dll
  6.  
  7. #then
  8. #odbc.defaultbinmode=1
  9. #odbc.defaultlrl=4096
  10. #odbc.max_links=-1
  11. #odbc.max_persistent=-1
  12. #odbc.check_persistent=On
  13. #odbc.allow_persistent=On
  14.  
  15. #credential
  16. $db_username = ''; //username
  17. $db_password = ''; //password
  18. //path to database file
  19. $database_path = 'D:\xampp\htdocs\absen_folder\Pga.mdb';
  20.  
  21. //check file exist before we proceed
  22. if (!file_exists($database_path)) {
  23.     die("Access database file not found !");
  24. }
  25.  
  26. //create a new PDO object
  27. $database = new PDO("odbc:DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=$database_path; Uid=$db_username; Pwd=$db_password;");
  28.  
  29. // simple query
  30. $sql  = "SELECT * FROM Process where ID = '00040531'";
  31. $result = $database->query($sql);
  32. while ($row = $result->fetch()) {
  33.     echo (string)$row["ID"]." ".$row["Name"];
  34.     echo "<br>";
  35. }
  36.  
  37. // join query
  38. // can't use JOIN, you should use INNER JOIN
  39. $sql  = "SELECT e.Name, e.ID, p.StartTime, p.EndTime, ClassWS, ClassWE FROM Process p INNER JOIN Employee e on e.ID = p.ID where e.ID = '00040531'";
  40. $result = $database->query($sql);
  41. echo "<Table border =1>";
  42. while ($row = $result->fetch()) {
  43.     echo (string)$row["ID"]." ".$row["Name"]." ".$row["StartTime"]." ".$row["EndTime"]." ".$row["ClassWS"];
  44.     echo "<tr><td>".(string)$row["ID"]."</td><td> ".$row["Name"]."</td><td> ".$row["StartTime"]."</td><td> ".$row["EndTime"]."</td><td> ".$row["ClassWS"]."</td></tr>";
  45.     echo "<br>";
  46. }
  47. ?>
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top