Connecting Tech Pros Worldwide Forums | Help | Site Map

PHP 4 compatible switchover (Help Needed)

Jon
Guest
 
Posts: n/a
#1: Jan 22 '06
function fetch_row($query, $autoclose = true)
{
if(is_string($query))
$query = self::query($query, true);
$return = mysql_fetch_row($query);
if($autoclose)
self::close($query);
return $return;
}

In PHP4 i get an error stating that the $query= self::query line
contains an "Undefined class name 'self'"

how, in general, can I take this and make it php4 compatible?$query is
defined as

function query($query, $return = false)
{
$fetch = mysql_query($query, $this->connection) or
die2(mysql_error($this->connection));
if($return)
return $fetch;

Any help would be appreciated...

Jon


Janwillem Borleffs
Guest
 
Posts: n/a
#2: Jan 22 '06

re: PHP 4 compatible switchover (Help Needed)


Jon wrote:[color=blue]
> In PHP4 i get an error stating that the $query= self::query line
> contains an "Undefined class name 'self'"
>
> how, in general, can I take this and make it php4 compatible?>[/color]

When the class is instantiated, simply replace "self::" with "$this->"; when
used statically, replace it with "ClassName::".


JW



Jon
Guest
 
Posts: n/a
#3: Jan 22 '06

re: PHP 4 compatible switchover (Help Needed)


On 2006-01-22 16:10:43 -0600, "Janwillem Borleffs" <jw@jwscripts.com> said:
[color=blue]
> Jon wrote:[color=green]
>> In PHP4 i get an error stating that the $query= self::query line
>> contains an "Undefined class name 'self'"
>>
>> how, in general, can I take this and make it php4 compatible?>[/color]
>
> When the class is instantiated, simply replace "self::" with "$this->";
> when used statically, replace it with "ClassName::".
>
>
> JW[/color]

Thanks for your post, I think this will be immesly helpful. Now, one
last question to set me straight. How can I tell when a class is
instantiated vs. statically?

Thanks a bunch!
jon

Janwillem Borleffs
Guest
 
Posts: n/a
#4: Jan 28 '06

re: PHP 4 compatible switchover (Help Needed)


Jon wrote:[color=blue]
> Thanks for your post, I think this will be immesly helpful. Now, one
> last question to set me straight. How can I tell when a class is
> instantiated vs. statically?
>[/color]

By the way it's called:

Instantiated: $class->method();
Statically: ClassName::method();


JW


Closed Thread