Beispiel #1
0
 public function getDb()
 {
     //echo "getDb: ". is_null($this->db_instance)."\n ".var_dump($this->db_instance);
     if (is_null($this->db_instance)) {
         $config = Config::getInstance(ROOT . '/public/Config.php');
         // echo $config->get('db_name')."<br>".$config->get('db_user')."<br>".$config->get('db_pass')."<br>"
         // .$config->get('db_host')."<br>";
         $this->db_instance = new MysqlDatabase($config->get('db_name'), $config->get('db_user'), $config->get('db_pass'), $config->get('db_host'));
     }
     return $this->db_instance;
 }
 public function __construct()
 {
     //        echo "tablePDO" .get_class($bd);
     $config = Config::getInstance(ROOT . '/public/Config.php');
     $this->db = new MysqlDatabase($config->get('db_name'), $config->get('db_user'), $config->get('db_pass'), $config->get('db_host'));
     //print_r(debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT));
     //print_r($this->db);
     if (is_null($this->table)) {
         //Factory
         $parts = explode('\\', get_class($this));
         $class_name = end($parts);
         $this->table = strtolower(str_replace('Table', '', $class_name));
     }
 }