Home > Archive > PHP DB > December 2007 > Re: [PHP-DB] Re: passing a mysqli object via globals
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Re: [PHP-DB] Re: passing a mysqli object via globals
|
|
| Dee Ayy 2007-12-03, 7:01 pm |
| On Dec 3, 2007 10:26 AM, julian <correojulian33-php@yahoo.es> wrote:
> Dee Ayy wrote:
>
>
> Not sure what you mean. global $db should bring to local scope a
> reference to the object that has the data base connection.
>
> PHP complaints that it cannot access properties or methods of that
> object in the obj/f1/ scope....
>
> I tried using the $GLOBALS['db'] with same results.....
In the one that failed, you used the invalid keyword "globals".
In the one that worked, you used the valid keyword "global".
When I said "hopefully", I was wondering if you could use
$GLOBALS['db'] but there may be other issues since you said that also
failed.
| |
| julian 2007-12-03, 7:01 pm |
| Dee Ayy wrote:
> On Dec 3, 2007 10:26 AM, julian <correojulian33-php@yahoo.es> wrote:
>
> In the one that failed, you used the invalid keyword "globals".
> In the one that worked, you used the valid keyword "global".
>
> When I said "hopefully", I was wondering if you could use
> $GLOBALS['db'] but there may be other issues since you said that also
> failed.
no worries.... I give up. It is really weird I know.... Hope some day I
will get enlighted.
In one file, any method within a class is happy with the global
$db...on a different (same file !!!) class no method is happy with
accessing $db via global...
I will open and close db connection in each method that it needs...
awkward...but works.
Thanks for your time.
| |
| julian 2007-12-04, 7:59 am |
| Dee Ayy wrote:
>
>
> So you confirmed that you are using "global" instead of what you
> posted to the list as "globals"?
yep sorry, as I mention it was a typo.. too upset to type everything
correctly.
However, it behaves the same way if I use $GLOBALS['db'].
I feel fresh and calm today... I will give it another try, separating
classes in different files and do some other teawking ... at least for
the time others are putting.
Cheers.
JCG
|
|
|
|
|