JayEdgar
Posts: 77
|
| Posted: 02/10/2008, 5:03 PM |
|
Hi all:
I have a function I'd like to put in the Common.php or Classes.php - one of the common files - so that I can call upon it from all of my pages.
The problem is, it appears I can't call
global $DBdb; #db is connection name
in the function - it says it object doesn't exist.
Can anyone advise me how to accomplish my goal?
Thanks much,
Jay
|
 |
 |
datadoit
|
| Posted: 02/10/2008, 6:08 PM |
|
If it's Common.php, may have to put your function at the bottom, or
after your DB connections are defined.
|
|
|
 |
JayEdgar
Posts: 77
|
| Posted: 02/10/2008, 6:13 PM |
|
Thanks datadoit, at the bottom is precisely where I placed the function. I guess I don't know where the object is defined, thus the request. 
Jay
|
 |
 |
JayEdgar
Posts: 77
|
| Posted: 02/10/2008, 6:21 PM |
|
Boy this is frustrating. I'm adding a function to the bottom of one of my regular pages and putting global $DBConnection; inside, and it's not working there either!
I even try sending the connection through to the function - no dice.
What am I missing?
Thanks,
Jay
|
 |
 |
wkempees
|
| Posted: 02/11/2008, 6:22 AM |
|
Your function as added to Common.php, inserted before the ?>
::
//MyFunction
function MyFunction()
{
$db = new clsDBConnection1();
...........
...........
$db->close();
return $Result;
}
//End MyFunction
This could also be the content of a file MyFunctionsLib.php
placed in its own directory within the published tree.
Any page would then do a include() or include_once() with the appropriate
filepath/filename
Walter
"JayEdgar" <JayEdgar@forum.codecharge> schreef in bericht
news:547af9ece3e8e1@news.codecharge.com...
> Hi all:
>
> I have a function I'd like to put in the Common.php or Classes.php - one
> of the
> common files - so that I can call upon it from all of my pages.
>
> The problem is, it appears I can't call
> global $DBdb; #db is connection name
> in the function - it says it object doesn't exist.
>
> Can anyone advise me how to accomplish my goal?
>
> Thanks much,
>
> Jay
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>
|
|
|
 |
JayEdgar
Posts: 77
|
| Posted: 02/11/2008, 7:03 AM |
|
Walter, that did it. Thank you very much!
Jay
|
 |
 |
DonP
|
| Posted: 02/11/2008, 10:58 AM |
|
The only time you can use:
global $DBConnection1;
is on a page with a grid or record that already has a database
connection established. The Common.php is not one of those so, as Walter
said, you need to create a new connection:
$db = new clsDBConnection1();
Don (DonP)
JayEdgar wrote:
> Hi all:
>
> I have a function I'd like to put in the Common.php or Classes.php - one of the
> common files - so that I can call upon it from all of my pages.
>
> The problem is, it appears I can't call
> global $DBdb; #db is connection name
> in the function - it says it object doesn't exist.
>
> Can anyone advise me how to accomplish my goal?
>
> Thanks much,
>
> Jay
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>
|
|
|
 |
JayEdgar
Posts: 77
|
| Posted: 02/11/2008, 11:01 AM |
|
Thanks for the clarification; it helps me understand. Some aspects of CC I make sing and dance, some of these subtleties I could still learn more about.
Jay
|
 |
 |
wkempees
|
| Posted: 02/11/2008, 1:32 PM |
|
For a better song and a closer dance, refer to CCS<version> not CC, which is
the 'other' product.
Regards,
Walter
"JayEdgar" <JayEdgar@forum.codecharge> schreef in bericht
news:547b09b9798e32@news.codecharge.com...
> Thanks for the clarification; it helps me understand. Some aspects of CC I
> make
> sing and dance, some of these subtleties I could still learn more about.
>
> Jay
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>
|
|
|
 |
JayEdgar
Posts: 77
|
| Posted: 02/11/2008, 1:38 PM |
|
LOL Thanks for the tip - I've only had CCS, so wasn't aware.
Cheers,
Jay
|
 |
 |
|