views:

197

answers:

1

I need to be able to connect to an MDB-file in a LAMP-environment (running on Linux) and ultimately insert converted data into a Mysql db.

  • The data I need to access is stored as a BLOB (Long Binary Data according to Access) in the MDB file. I have not yet been able to actually have a look at the data but I have been told that the BLOB consists of byte strings. Something along the lines of:

    0x1c 0x10 0x27 0x00 0x00

  • I need to parse the byte strings and convert these to a format that is
    human readable. I do have access to
    the documentation that explains the
    various byte strings.

So this is really two questions:

  1. How do a get access to the MDB file via PHP* (running under LAMP) and read the BLOB (I do not have access to a Windows-platform)?
  2. What would be the best way to parse the binary data (in PHP*) once I am able to connect to the MDB-file?

*Or are there other methods/languages that are more appropriate?

+2  A: 

There is a PECL library that connects to a Linux based MDB parsing tool.

Reading Access Databases with PHP and PECL

In this article, I'll introduce you to PHP's MDBTools extension, which provides an API to programmatically read data from Microsoft Access database files. If your project involves working with such files, extracting database records either for calculations or for conversion to other formats, you'll find this extension invaluable. Come on in, and see how it works!

You will probably need administrator access on the server to install the necessary libraries.

If you can use a Windows server, you should be able to connect to the file directly using ODBC using ADODb or through the windows COM as shown in this blog entry.

Pekka
Unfortunately, I do not have access to a Windows server. Production will be in a hosted environment running LAMP. I just checked and my provider does not have mdbtools. I've looked at using PDO as described here: http://stackoverflow.com/questions/1605473/how-to-operate-access-with-php but it would appear that PHP in the hosted environment is compiled withput support for PDO/ODBC. Oh well ...
BusterX
@Buster I think any PDO/ADOdb/ODBC based solution would always need a live data source reading the MDB file - something that AFAIK you can get only on Windows. Too bad... You may have to do a conversion into something more easy to read, e.g. CSV or Excel.
Pekka
@Pekka I was getting my hopes up reading about PDO (and ADOdb) and using a DSN-less connection but it appears that both models require Windows. *sigh* ... Well, we're still left with part 2 of my question so maybe we could focus on that while I go and find a VPS provider that will allow me to install Windows?
BusterX
@BusterX yup, it looks like you'd need a PHP library to read raw MDB files to do this.
Pekka
@Buster the second part of your question is not really clear. What do you mean by "human readable"? Plus, it would be worth a question on its own IMO.
Pekka
Pekka
@Pekka You are probably right about part 2 being worthy of it's own questions. In brief, the byte strings will need to be converted to integers (via math and algorithms that I have available in the docs). The end result will be a two-column db table containing integers.
BusterX
@Buster yup, sounds like an own question, except if you're looking for ord() http://www.php.net/ord
Pekka