I have 2 classes: one is an DBobject which contains general database query and the other child classes that each has a specific database query. Now the problem is when I try to initialize the parent class table_name variable it is not being initialized. I have tried many ways but it shows that the table is empty when the query is performed. Here's the code:
<?php
class DBobject {
public static $table_name="";
public static function find_all(){
global $database;
return self::find_by_sql("SELECT * FROM ".self::$table_name);
}
}
?>
<?php
class Catagory extends DBobject{
public static $table_name ="catagory";
}
?>
?>
The main application:
<?php
$cata = Catagory::find_all();
foreach($cata as $catag){
echo "Catagory Name :" . $catag->name."<br/>";
}
?>
I want to be able to initialize the type of the table that the DBobject function find_all() will work on. Please help me with this. This is the error that I get. Noticet that the query does not contain the name of the table.
Database query Failed You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
last SQL query: SELECT * FROM