How to connect to the odbc data source in php and save and query data

Source: Internet
Author: User
Tags echo date
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.