simple enough.
let's show it by an exemple
$dbname="name_of_your_odbc_datasource";
$dbuser="login_to_the_database";
$dbpass="password";
//first you have to create a connection
$conn=odbc_connect($db,$dbuser,$dbpass);
//now you can create query and access the database through odbc
$sel="select * from table";
$res=odbc_exec($conn,$sel);
odbc_result_all($res); // fast way to see all the data returned by the query
//or you can do it this way too.
while (odbc_fetch_row($res)) {
$data=odbc_result($res,1);
$data2=odbc_result($res,2);
echo $data."<BR>".$data2."<HR>";
}
odbc_free_result($res);
odbc_close($conn);
for more information check the php manual entry on unified odbc functions
Khaldryck
Programmer at the University of Brussel (Belgium)
There is also a 'database extraction layer' you can use which provides a very simple 'API' for use to connect to a large number of databases. This is for COM use utilizing both ODBC and OLEdb. This way, in the future, if you switch to Oracle, Sybase, MySQL, etc. it takes only 1-2 lines of change:
Here is a good place to download an ADODB library for you to use with your PHP applications:
This class library currently supports MySQL, PostgreSQL, Interbase, Oracle, MS SQL 7, Foxpro, Access, ADO, Sybase and generic ODBC. The Sybase and PostgreSQL drivers are community contributions.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.