This article describes how to connect php to the odbc data source and store and query data. it involves the operation skills of the odbc data source and is very useful, for more information about how to connect php to the odbc data source and save and query data, see the following example. Share it with you for your reference.
The specific implementation code is as follows:
The code is as follows:
$ Connstr = "driver = microsoft access driver (*. mdb); dbq =". realpath ("db. mdb ");
$ Connid = odbc_connect ($ connstr, "", "", SQL _cur_use_odbc );
$ Odbc_exec = odbc_exec ($ connid, "insert into tablename (name) values ('name ')");
$ Query = odbc_do ($ connid, "select * from tablename ");
$ Odbc_result_all = odbc_result_all ($ query );
Echo $ odbc_result_all;
// Save data
$ Connstr = "driver = microsoft access driver (*. mdb); dbq =". realpath ("db. mdb ");
$ Connid = odbc_connect ($ connstr, "", "", SQL _cur_use_odbc );
$ Odbc_exec = odbc_exec ($ connid, "insert into t ...... ")
// Query data
$ A = 0;
$ Begintime = time ();
While ($ a <100)
{
$ Conn = odbc_connect ("forphp", "sa", "sa ");
// Odbc_select_db ("[testyouhui]", $ conn );
$ Result = odbc_exec ("select [id], [name] from [test1]. [dbo]. [category]", $ conn); // open-source code phpfensi.com
$ A ++;
Odbc_close ($ conn );
}
$ Endtime = time ();
Echo $ begintime ."
";
Echo $ endtime ."
";
Echo date ('U second ', $ endtime-$ begintime );
Echo'
';
I hope this article will help you with php programming.