Trying to fix deprecated functions

Open to all! Ask other shopowners for help.
Post Reply
gsmiley007
Member
Posts: 82
Joined: Sun Mar 14, 2021 9:28 pm
Phoenix Version:
Has thanked: 9 times
Been thanked: 2 times

Trying to fix deprecated functions

Post by gsmiley007 »

So i'm use the @raiwa spreadsheet

tep_db_query("SHOW CHARACTER SET") $db->query("SHOW CHARACTER SET")

for an plugin in the admin.

it throws an error

[05-Aug-2023 23:28:19 America/Toronto] PHP Warning: Undefined variable $db
[05-Aug-2023 23:28:19 America/Toronto] PHP Fatal error: Uncaught Error: Call to a member function query() on null


Join The Code Co-op to get access to your library in the Code Co-op Forum
User avatar
Kofod95
Senior Contributor
Posts: 748
Joined: Sat Feb 06, 2021 7:38 pm
Phoenix Version: 1.0.8.20
Has thanked: 99 times
Been thanked: 179 times

Re: Trying to fix deprecated functions

Post by Kofod95 »

Try

Code: Select all

$GLOBALS['db']->query("SHOW CHARACTER SET")
If application_top isn't loaded in the file directly, we need to fetch the classes from the global.

At times, we might also be calling classes (via hooks) before they are instanciated in application_top. In those cases there is the Guarantor::ensure_global() method. If called inside an action or similar, add a \ (I think that is due to name spaces, but I really don't understand that much) ;)

//Daniel
I'm not smart, but sometimes even a blind chicken can find a corn.
Here are a lot of corns: Phoenix user guide
gsmiley007
Member
Posts: 82
Joined: Sun Mar 14, 2021 9:28 pm
Phoenix Version:
Has thanked: 9 times
Been thanked: 2 times

Re: Trying to fix deprecated functions

Post by gsmiley007 »

thanks, that worked


Join The Code Co-op to get access to your library in the Code Co-op Forum
Post Reply