Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- #October 3, 2017
- #First activate pdo_odbc in your server
- #extension=php_pdo_odbc.dll
- #then
- #odbc.defaultbinmode=1
- #odbc.defaultlrl=4096
- #odbc.max_links=-1
- #odbc.max_persistent=-1
- #odbc.check_persistent=On
- #odbc.allow_persistent=On
- #credential
- $db_username = ''; //username
- $db_password = ''; //password
- //path to database file
- $database_path = 'D:\xampp\htdocs\absen_folder\Pga.mdb';
- //check file exist before we proceed
- if (!file_exists($database_path)) {
- die("Access database file not found !");
- }
- //create a new PDO object
- $database = new PDO("odbc:DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=$database_path; Uid=$db_username; Pwd=$db_password;");
- // simple query
- $sql = "SELECT * FROM Process where ID = '00040531'";
- $result = $database->query($sql);
- while ($row = $result->fetch()) {
- echo (string)$row["ID"]." ".$row["Name"];
- echo "<br>";
- }
- // join query
- // can't use JOIN, you should use INNER JOIN
- $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'";
- $result = $database->query($sql);
- echo "<Table border =1>";
- while ($row = $result->fetch()) {
- echo (string)$row["ID"]." ".$row["Name"]." ".$row["StartTime"]." ".$row["EndTime"]." ".$row["ClassWS"];
- echo "<tr><td>".(string)$row["ID"]."</td><td> ".$row["Name"]."</td><td> ".$row["StartTime"]."</td><td> ".$row["EndTime"]."</td><td> ".$row["ClassWS"]."</td></tr>";
- echo "<br>";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement