Example #1
0
 public static function run()
 {
     if (!isset(self::$_instance)) {
         self::$_instance = new DB();
     }
     return self::$_instance;
 }
Example #2
0
 public static function getInstance()
 {
     if (FALSE == self::$_instance instanceof self) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
Example #3
0
 public function query($query)
 {
     if (stripos(ltrim($query), 'SELECT') === 0) {
         return coreDB::dbGetData($query);
     } else {
         return coreDB::dbSetData($query);
     }
 }
Example #4
0
 /**
  * 连接到从数据库
  * @param $host
  * @param $port
  * @param $username
  * @param $password
  */
 private function connSlave($host, $port, $username, $password)
 {
     if (!self::$slave) {
         self::$slave = $this->setConnect($host, $port, $username, $password);
     }
 }
Example #5
0
 /**
  * 删除数据
  * @param  [type]  $table     [description]
  * @param  [type]  $condition [description]
  * @param  integer $limit     [description]
  * @return [type]             [description]
  */
 public static function delete($table, $condition, $limit = 0)
 {
     if ($limit) {
         $limit = intval($limit);
     }
     self::$sql = "DELETE FROM " . self::table($table) . " where " . $condition . " limit " . $limit;
     return self::exec();
 }