Jump to content

Prevent database connection as a parameter to all function


Recommended Posts

HI, i'm using a class to create a database connection etc..

So I have something like this in a common.inc.php file which is include in each page

$db_numbers_args = array();
$db_numbers_args['host'] = "localhost";
$db_numbers_args['user'] = "puser";
$db_numbers_args['pass'] = "nuser";
$db_numbers_args['db']   = "nu_name";
$db_numbers = new db($db_numbers_args,TRUE);

 

From there I can end up making query's like $res = $db_numbers->query($uqs);

 

So that said i'm including another file that contains all functions, when  the functions need to do database transactions I always need to put $db_numbers as a paramter to the function and each function I make..

How should I make this better ?

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.