Page 1 of 1
Database Connection Global
Posted: Wed May 21, 2003 2:59 pm
by timbiotic
Is it possible to create an ADO connection that will stay global within all of my functions? Or will i need to setup the connection in all of the functions?
Thanks,
timbiotic
Make a seperate file
Posted: Thu May 22, 2003 6:17 am
by coolpravin
Make a seperate file for connection.
Here define the connection variables and connect to database.
You can do this in config file also.
THen include this file in each of your coding file and you will get the connection.
For functions , inside function just define the connection variable as global
Code: Select all
e.g function findusers()
{
Global $db;
//function code
}
And all of your work will be done.
THANK YOU!!!
Posted: Thu May 22, 2003 1:33 pm
by timbiotic

That DID IT!!! Thanks much!!!

Another Question
Posted: Thu May 22, 2003 2:29 pm
by timbiotic
Since switching to ADO i have had to adjust to non ODBC calls. What is the equivalent of odbc_fetch_row?
I can't seem to get the syntax right with ADO:
Former
Code: Select all
while($row = odbc_fetch_row($sql_results))
{ //process stuff }
Code that wont work now:
Code: Select all
while($row = $sql_results-> FetchRow())
{ //process stuff }
Any ideas what i am doing wrong?
Thanks,
timbiotic