Phpodbc_connect () function description and instance code _ PHP Tutorial

Source: Internet
Author: User
Phpodbc_connect () function description and instance code. Connect to the ODBCodbc_connect () function to connect to the ODBC data source. This function has four parameters: data source name, user name, password, and optional pointer type parameters. The function connecting to odbco to connect to ODBCodbc_connect () is used to connect to the ODBC data source. This function has four parameters: data source name, user name, password, and optional pointer type parameters.

Connect to odbc
The odbc_connect () function is used to connect to the odbc data source. This function has four parameters: data source name, user name, password, and optional pointer type parameters.

The odbc_exec () function is used to execute SQL statements.

$ Db_user = "dbuser"; // define the connection user name
$ Db_pass = "dbpass"; // password of the connected user
$ Dsn = "dsn"; // defines the dsn data source
If (odbc_connect ($ dsn, $ db_user, $ db_pass) // connect to the odbc data source
{
Echo "successfully connected to the odbc data source"; // if the output is successful
}
Else
{
Echo "an error occurred while connecting to odbc! "; // If the output fails
}

Odbc_close_all (); // close all opened connections
Echo "all open odbc connections have been closed! "; // Output content after the function is executed


View a more advanced connection to the host

$ Db_host = "server. mynetwork"; // defines the host name.
$ Db_user = "dbuser"; // define the connection user name
$ Db_pass = "dbpass"; // defines the user's password.
$ Dsn = "dsn"; // defines a dsn
$ Result = odbc_pconnect ($ dsn, $ db_user, $ db_pass); // open a valid odbc Connection
If ($ result) // judge the result
{
Echo "open a valid connection"; // The Output Content is successfully executed.
}
Echo"
";
If (odbc_close ($ result) // try to close the connection
{
Echo "disabled? "; // If the output content is disabled successfully
}
Else
{
Echo "cannot be closed! "; // If the output fails to be disabled
}

Query Database tutorials

Connect to the data source

$ My_ SQL = "select * from usertable"; // define an SQL statement
$ Result = odbc_do ($ myconn, $ my_ SQL); // execute an SQL statement
Echo odbc_num_rows ($ result );
Echo"













N ";Echo" N ";Echo" N ";Echo" N ";Echo" N ";Echo" N ";While (odbc_fetch_row ($ result )){Echo" N ";Echo" N ";Echo" N ";Echo" N ";Echo" N ";}Echo"
ID numberNameAddress
". Odbc_result ($ result, 1 )."". Odbc_result ($ result, 2 )."". Odbc_result ($ result, 3 )."
";


Related

Odbc_free_result ($ result); // release the memory occupied by SQL statements.
Echo "the memory occupied by the result set has been successfully released! ";
Odbc_rollback ($ myconn) cancels all uncommitted operations
Odbc_commit ($ myconn) // submit all uncommitted operations
Odbc_autocommit ($ myconn, false); // disable automatic commit
Odbc_columnprivileges ($ myconn, "dbuser", "administrator", "usertable", "name"); // lists the columns and permissions of a given table
$ Result = odbc_columns ($ myconn); // lists the names of columns in the specified table.
Echo odbc_result_all ($ result );

The export ODBCodbc_connect () function is used to connect to the ODBC data source. This function has four parameters: data source name, user name, password, and optional pointer type parameters. Connect to odbc o...

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.