コード例 #1
0
ファイル: Pro_Db.php プロジェクト: eywalink/worktime
 public static function get_mysql()
 {
     if (!self::$_mysql) {
         self::$_mysql = new Lib_Mysql(Config_Common::$db);
     }
     return self::$_mysql;
 }
コード例 #2
0
ファイル: Ctl_Role.php プロジェクト: eywalink/worktime
 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);
         }
     }
 }
コード例 #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());
 }
コード例 #4
0
ファイル: Lib_Model.php プロジェクト: eywalink/worktime
 public function get_db()
 {
     return Pro_Db::get_mysql();
 }