Exemplo n.º 1
0
 public static function get_mysql()
 {
     if (!self::$_mysql) {
         self::$_mysql = new Lib_Mysql(Config_Common::$db);
     }
     return self::$_mysql;
 }
Exemplo n.º 2
0
 public function init_db_structure()
 {
     $db = Pro_Db::get_mysql();
     $db_name = Config_Common::$db['dbname'];
     $sql_file = 'install.sql';
     $sql = file_get_contents($sql_file);
     $sql = trim($sql);
     $sql = str_replace("\r", "\n", str_replace('common_db_name', $db_name, $sql));
     $a = array();
     $i = 0;
     $tables = explode(";\n", $sql);
     foreach ($tables as $table) {
         $a[$i] = '';
         $queries = explode("\n", trim($table));
         foreach ($queries as $query) {
             $a[$i] .= isset($query[0]) && $query[0] == '#' || isset($query[1]) && $query[0] . $query[1] == '--' ? '' : $query;
         }
         $i++;
     }
     foreach ($a as $query) {
         $query = trim($query);
         if ($query) {
             $db->query($query);
         }
     }
 }
Exemplo n.º 3
0
 public function delete()
 {
     $t = new Lib_Keyvalue();
     $t->set_db_key($this->get_db_key());
     $t->set_table($this->get_table());
     $sql = 'delete from ' . $t->get_table() . ' where id="' . $this->id . '"';
     $db = Pro_Db::get_mysql();
     $db->query($sql);
     $memcache = $t->get_memcache();
     $memcache->delete($this->get_memcache_key());
 }
Exemplo n.º 4
0
 public function get_db()
 {
     return Pro_Db::get_mysql();
 }