[Help] What are the database connection methods ??

Source: Internet
Author: User
[Help] What are the database connection methods ?? -- Linux general technology-Linux technology and application information. For details, refer to the following section. 1. There are three main database connection methods:
A. ODBC (divided into creating data sources and not creating data sources)
(1) Create a system data source. Use the ODBC function provided by PHP. (Debugging has a problem !!!!!!!)
Establish an odbc driver and connect it with the odbc_connect () function of php.
Reference content is as follows:
For example: $ connstr = DRIVER = {Microsoft Access Driver (*. mdb)}; DBQ = ". $ db;
$ Connid = odbc_connect ($ connstr, "username", "password", SQL _CUR_USE_ODBC );
(2) No need to create a data source (debugging successful !)
$ Connstr = "DRIVER = {Microsoft Access Driver (*. mdb)}; DBQ =". realpath ("db/test. mdb ");
$ Connid = odbc_connect ($ connstr, "", "", SQL _CUR_USE_ODBC );
$ SQL = "select * from userinfo ";
$ Result = odbc_exec ($ connid, $ SQL); // execute an SQL statement

If ($ result) echo "successful ";
Else echo "failed ";
B. ADODB (debugging successful !)
$ Conn = new com ("ADODB. Connection ");
$ Connstr = "DRIVER = {Microsoft Access Driver (*. mdb)}; DBQ =". realpath ("db/test. mdb ");
$ Conn-> Open ($ connstr );
$ Rs = new com ("ADODB. RecordSet ");
$ Rs-> Open ("select * from userinfo", $ conn, 1, 2 );
******************
C. OLE_DB (similar to the connection string type) (debugging failed !!)
Use oledb to connect and then call the open Method to open
For example, the reference content is as follows:
$ Conn = new com ("ADODB. connection ");
$ Connstr = "Provider = Microsoft. Jet. OLEDB.4.0; Data Source =". $ db;
$ Conn-> Open ($ connstr );
========================================================== ====
What should I do if the above failed connections are correct ???
What are the scenarios where ODBC has data sources and data sources ?? There are three main Database Connection Methods: ODBC, OLE_DB, and ADODB. What are their differences? Which one is better ??
In addition, when using ODBC to connect to a database, you can establish a data source connection or do not need to establish a data source connection. What is the difference ??
If there is a difference, where are they used ?? Please explain in detail ????
Related Article

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.