Database Connection Global

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
timbiotic
Forum Newbie
Posts: 14
Joined: Thu Feb 13, 2003 3:16 pm

Database Connection Global

Post 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
User avatar
coolpravin
Forum Newbie
Posts: 20
Joined: Mon May 19, 2003 12:56 am
Location: India

Make a seperate file

Post 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.
timbiotic
Forum Newbie
Posts: 14
Joined: Thu Feb 13, 2003 3:16 pm

THANK YOU!!!

Post by timbiotic »

:D That DID IT!!! Thanks much!!! :lol:
timbiotic
Forum Newbie
Posts: 14
Joined: Thu Feb 13, 2003 3:16 pm

Another Question

Post 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
Post Reply