This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ===== SIC PHP ===== <code> apt-get install php odbc-mdbtools php-odbc php-mbstring </code> ==== Play ==== Install mdbtools on local machine <code> sudo apt-get install mdbtools </code> Start mdb-sql: <code> mdb-sql SicDB.mdb </code> === List tables === <code> list tables go </code> === Describe tables === <code> describe table SIC0001F go </code> === SIC Tables === <code> +------------------------------+ |Tables | +------------------------------+ |SIC0001F | Personas físicas |SIC0001J | Personas jurídicas |SIC0001A | Last modification +------------------------------+ </code> === Query an ID (cédula) === <code> select CEDULA,NOMBRE,APELLIDOS from SIC0001F where CEDULA like '%112540139%' go </code> === Query example with PHP === On server: <code> <?php $query = 'select CEDULA,NOMBRE,APELLIDOS from SIC0001F where CEDULA like \'%112540139%\''; $mdb_file = 'SicDB.mdb'; $driver = 'MDBTools'; $dataSourceName = "odbc:Driver=$driver;DBQ=$mdb_file"; $connection = new \PDO($dataSourceName); $result = $connection->query($query)->fetchAll(\PDO::FETCH_ASSOC); print_r($result); ?> </code> === Export to MariaDB === == Tables == <code> mdb-export SicDB.mdb SIC0001F > SIC0001F.csv mdb-export SicDB.mdb SIC0001J > SIC0001J.csv mdb-export SicDB.mdb SIC0001A > SIC0001A.csv </code> == Schema == <code> mdb-schema SicDB.mdb | sed "s/^-/#/;s/\[//g;s/\]//g" > sicdb.sql </code> === Install MariaDB === <code> sudo apt-get install mariadb-server mariadb-client php-mysql </code> === Import to MariaDB === <code> MariaDB [(none)]> create database sicdb; </code> <code> cat sicdb.sql | mysql -u root sicdb </code> <code> mysqlimport --ignore-lines=1 --fields-terminated-by=, --fields-enclosed-by=\" -u root --local -p sicdb SIC0001J.csv mysqlimport --ignore-lines=1 --fields-terminated-by=, --fields-enclosed-by=\" -u root --local -p sicdb SIC0001F.csv </code> === PHP === <code> <?php $query = 'select CEDULA,NOMBRE,APELLIDOS from SIC0001F where CEDULA like \'%112540139%\''; $connection = new PDO('mysql:host=localhost;dbname=sicdb', 'sicdb', 'sicdb'); $result = $connection->query($query)->fetchAll(\PDO::FETCH_ASSOC); print_r($result); ?> </code> ==== Troubleshooting ==== To fix this error: <code> Can't open cursor lib '/etc/libodbccr.so' : file not found </code> cd /usr/lib/x86_64-linux-gnu ln -s libodbccr.so.2 libodbccr.so </code> ==== References ==== * https://bugzilla.redhat.com/show_bug.cgi?id=719595 * https://www.systutorials.com/docs/linux/man/1-mdb-sql/ * https://stackoverflow.com/questions/15896046/where-clause-not-working-in-sql-query-using-mdbtools * https://stackoverflow.com/questions/6072883/connect-to-ms-access-remote-mdb-file-from-php-on-linux * http://notes.tomcarlson.com/mdb-to-mysql * http://wiki.hashphp.org/PDO_Tutorial_for_MySQL_Developers * https://stackoverflow.com/questions/25231153/show-load-time-on-page