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