Using PHP to query a MDB file, and return JSON

前端 未结 4 1114
你的背包
你的背包 2021-01-25 07:46

I have a Microsoft Access Database, and I am trying to query the table using PHP, and output valid JSON. I have an equivalent code for a MSSQL database, am I am trying to make m

4条回答
  •  走了就别回头了
    2021-01-25 08:02

    odbc_connect doesn't return an object, it returns a resource. see (http://php.net/manual/en/function.odbc-connect.php) so you would need to do something like this.

     $db = odbc_connect("Driver={Microsoft Access Driver (*.mdb)};Dbq=$dbName", $user, $password);
     $oexec = obdc_exec($db,$sql);
      $result[] = odbc_fetch_array($oexec);
    

    and then you can iterate over results..

    see also:

    http://www.php.net/manual/en/function.odbc-fetch-array.php http://www.php.net/manual/en/function.odbc-exec.php

提交回复
热议问题