In a table class I want to use simple functions but also static functions, how can I do? Here is my current code (which does not work)
In my controller, I just want to do: Table::get('posts')
which directly invokes the function check_table($table)
.
<?php
namespace Fwk\ORM;
use Fwk\Application;
use Fwk\Database\Database;
class Table extends Application {
public function __construct()
{
$this->db = new Database();
}
public static function get($table) {
if($this->check_table($table)) {
return "ok";
}
}
public function check_table($table) {
$r = $this->$db->query("SELECT 1 FROM $table");
return $r;
}
}
?>