Using PHP and MySQL to connect to ODBC data _php tutorial

Source: Internet
Author: User
ODBC refers to the Open data connection, which is Microsoft-led data driver, it can connect with other data, through the SQL language to manipulate the data, of course, PHP also provides a function of the ODBC data connection,
The connection between PHP and ODBC is mainly accomplished by several functions,
Let's first recognize a few functions with the ODBC interface:
int Odbc_connect (string dsn, string user, string password, int [cursor_type]), is connected to the ODBC database
DSN, User,password is the content that corresponds to ODBC, Cursor_type is the choice cursor type, (can examine other documents, here I use it default value)
int Odbc_do (int connection_id, string query) is a function that executes the SQL language, connecton_id is the value odbc_connecti back, and query is the SQL language statement that we care most about,
String Odbc_result (int result_id, mixed field), is the function that takes the data, result_id is the Odbc_do execution return value, field is the index value
void odbc_close (int connection_id); The data connection is closed.
We first use these functions to connect with ODBC.
We assume that the DSN set in ODBC is Yuange user and password can not, of course, if you want to connect with SQL Server need user and password!
There's a watch in Yuange, counter.

$conid =odbc_connect ("Yuange", "", "" ");
$sql = "SELECT * from Counter";
$resid =odbc_do ($conid, $sql);
while (Odbc_fetch_row ($resid)) {
$serial =odbc_result ($resid, 1);
$riqi =odbc_result ($resid, 2);
if ($serial%2) {
echo $serial. " ". $riqi."
";
}
}
Odbc_close ($conid);
?>
I'm Win98 the PWS plus the php4.0 and mysql3.02 versions are working well.

"The copyright of this article is owned by the author and house Orso near net, if need to reprint, please specify the author and source"


http://www.bkjia.com/PHPjc/316446.html www.bkjia.com true http://www.bkjia.com/PHPjc/316446.html techarticle ODBC refers to the Open data connection, it is the Microsoft-led data driver, it can connect with other data, through the SQL language to manipulate the data, of course, PHP also provides a connection to the ODBC data ...

  • 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.