Re: mdbtools with php

"Dale Scott" <[email protected]> Wed, 6 Apr 2011 22:31:01 -0600
Newsgroups gmane.comp.db.mdb-tools.devel
Message-ID <[email protected]>
Thanks Jakob (and everyone else who replied). I'm making progress using the
command line utilities from PHP now and so far so good. All should be good
as I just need to periodically synchronize a MySQL database with a
medium-size Access database - at least nightly but maybe hourly, and
possibly user initiated when it's necessary to pull immediately from Access
to MySQL (mentioning this in case someone can say from experience it will be
way too slow to be practical).

 

And now just another couple questions..

 

1)      At least on my FreeBSD system, the mdbtools-0.5 utilities are
dynamically linked while compiling from the github head gives statically
linked utilities. Does anyone know if this is unique to FreeSD, or if it's
just a change in the way mdbtools compiles? (and why?)

 

2)      The database I'm reading from has a couple tables "hidden" from
Access (or rather, they seem to be "System objects" and have to be
specifically unhidden to be visible). Mdb-tables in Mdbtools-0.5 returns all
the tables, including the "hidden" ones, but the latest mdb-tables does not
return these tables (just all the others). Anyone know why? (I can probably
manage without the "hidden" tables, but one of them has username/passwords I
was hoping to use to authenticate web users hitting the MySQL database) I
can send an example database if anyone wants to take a look.

 

Dale

 

From: Jakob Egger [mailto:[email protected]] 
Sent: Sunday, March 27, 2011 2:56 AM
To: Dale Scott
Subject: Re: [mdb-dev] mdbtools with php

 

Hi Dale,

 

I found it easiest to simply call the command line tools from php
(mdb-tables and mdb-export), and parse the data using the CSV functions in
PHP.

 

However, it only makes sense if you access data a table at a time. If you
only need a few records, this method is probably very slow.

 

As an example, here's how I read MDB databases from within php:

 

<?php

 

$file = "NWind.mdb";

foreach(tablesInFile($file) as $table) {

            echo "<h1>".htmlspecialchars($table)."</h1>";

            echo "<table>";

            foreach(rowsInTable($file, $table) as $row) {

                        echo "<tr>";

                        foreach($row as $columnName=>$columnValue) {

                                    echo
"<td>".htmlspecialchars($columnValue)."</td>";

                        }

                        echo "/<tr>";

            }

            echo "</table>";

}

 

function tablesInFile($file) {

            exec("/usr/bin/mdb-tables -1 " . escapeshellarg($file), $tables
);

            return $tables;

}

 

function rowsInTable($file, $table) {

            $csv = popen("/usr/bin/mdb-export -q \\\ <smb://> " -X \\\\
<smb://>  " . escapeshellarg($file) . " " . escapeshellarg($table), "r");

            $header = fgetcsv($csv);

            $rows = array();

            while($row=fgetcsv($csv)) {

                        $rows[] = array_combine($header, $row);

            }

            return $rows;

}

 

?>

 

 

Best regards,

Jakob

 

 

On 26.03.2011, at 21:15, Dale Scott wrote:





Hi, how is mdbtools being used with php? I first tried pecl-mdbtools. Now
I'm trying ODBC (via unixODBC). Are there other and/or better methods?

 

Also, I'm having trouble with either unixODBC or mdbtools segfaulting when I
try to open a database, so I'm rebuilding everything from scratch on a new
install of FreeBSD-7.4-RELEASE with latest ports to make sure I don't have a
problem with wrong versions of libraries or something. If anyone has any
suggestions, I'm all ears (it will be tomorrow until I can run the tests
again).

 

Dale

 

 

----------------------------------------------------------------------------
--
Enable your software for Intel(R) Active Management Technology to meet the
growing manageability and security demands of your customers. Businesses
are taking advantage of Intel(R) vPro (TM) technology - will your software 
be a part of the solution? Download the Intel(R) Manageability Checker 
today!
http://p.sf.net/sfu/intel-dev2devmar________________________________________
_______
mdbtools-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mdbtools-dev

------------------------------------------------------------------------------
Xperia(TM) PLAY
It's a major breakthrough. An authentic gaming
smartphone on the nation's most reliable network.
And it wants your games.
http://p.sf.net/sfu/verizon-sfdev

_______________________________________________
mdbtools-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mdbtools-dev