We have an MS Access attendance database, which is updated by biometric hardware. So there is no way to replace MS Access. Now we need to provide the attendance information on our intranet web, for which we are trying to periodically read the MS-Access mdb file on a Windows XP computer, and write to a postgres database through php. PHP - Postgres - Apache are running on Ubuntu 10.04 Server. html pages /reports are to be displayed from the server. When using MDB tools to connect to the MS-Access mdb file from php, only the Number and Date/Time fields are returned (though as String). The Text fields return NULL.
The PHP code is as follows:
$dbName = "/media/winshare/attEngine.mdb";
if (!file_exists($dbName))
die("Could not find database file.");
$dbconn = new PDO("odbc:DRIVER=MDBTools; DBQ=$dbName; Uid=admin; Pwd=pswd;");
if ($dbconn) {
echo "mdb connection established.<br />\n";
} else {
die ("mdb connection could not be established.<br />\n");
}
$qry = "SELECT transactionId, aDate, aDateTime, EmpCode, EmpName, ControllerNum FROM Transactions;";
$dbqryprep = $dbconn->prepare($qry);
$dbqryprep->execute();
$result = $dbqryprep->fetchall(PDO::FETCH_ASSOC);
echo "QRY RESULT (from Access):<pre>\n";
var_dump($result);
echo "\n</pre>\n";
Here: transactionId is AutoNumber in Access; aDate, aDateTime are Date/Time; EmpCode is Number; and EmpName and ControllerNum are Text fields in Access.
When we load the php, it gives result as follows (only first two array-elements shown):
mdb connection established.
QRY RESULT (from Access):
array(31986) {
[0]=> array(7) {
["transactionId"]=> string(3) "341"
["aDate"]=> string(17) "11/23/13 00:00:00"
["aDateTime"]=> string(17) "11/23/13 13:01:07"
["EmpCode"]=> string(1) "0"
["EmpName"]=> NULL
["ControllerNum"]=> NULL
}
[1]=> array(7) {
["transactionId"]=> string(3) "342"
["aDate"]=> string(17) "11/23/13 00:00:00"
["aDateTime"]=> string(17) "11/23/13 13:01:12"
["EmpCode"]=> string(1) "0"
["EmpName"]=> NULL
["ControllerNum"]=> NULL
}
Actually I have 2 questions:
What could be the problem in my using MDBTools as above?
Or is it better to run / schedule scripts on the Windows computer to connect through odbc to Access and postgres, and transfer data? If so what are the best scripts for that?