4

Possible Duplicate:
Access from PHP to .mdb file on Ubuntu

Hi I'm developing a webstore using the php framework yii..

I want to upload a .mdb file to our system, and extract data from it and insert into mysql database..

Is there anyway of doin this?

It'll be great if someone could help me out.

Thanks

Community
  • 1
  • 1
era
  • 535
  • 1
  • 8
  • 16
  • check here: http://devzone.zend.com/1315/reading-access-databases-with-php-and-pecl/ –  May 22 '12 at 07:19
  • check http://stackoverflow.com/questions/5722544/how-can-i-convert-an-mdb-access-file-to-mysql-or-plain-sql-file – Dolly May 22 '12 at 07:20
  • @cutebabs I think those are manual tools, and OP is looking for something that can be automated – eis May 22 '12 at 07:23

2 Answers2

6

Use odbc_connect() function using a database source name (DSN). Alternatively, a DSN-less connection string can be used.

DSN-less connections

if no password, leave username as "sa" and password blank.

$conn = odbc_connect("Driver={Microsoft Access Driver (*.mdb)};Dbq=$mdb_file", $user, $password);

To Connect with DSN

from *http://www.w3schools.com/php/php_db_odbc.asp*

Open the Administrative Tools icon in your Control Panel Double-click on the Data Sources (ODBC) icon inside. Choose the System DSN tab. Click on Add in the System DSN tab. Select the Microsoft Access Driver. Click Finish. In the next screen, click Select to locate the database. Give the database a Data Source Name (DSN). Click OK.

$conn = odbc_connect($dsn_name, $user, $password);

Query:

$res = odbc_exec($conn, "select * from table");

List results:

while( $row = odbc_fetch_array($res) ) { 
    print_r($row); 
}

More info: http://www.php.net/manual/en/ref.uodbc.php

0

read the data from mdb to csv

read from csv and insert into mysql

Satya
  • 8,693
  • 5
  • 34
  • 55