Exemple #1
0
 public static function run()
 {
     if (!isset(self::$_instance)) {
         self::$_instance = new DB();
     }
     return self::$_instance;
 }
Exemple #2
0
 public static function getInstance()
 {
     if (FALSE == self::$_instance instanceof self) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
Exemple #3
0
 public function query($query)
 {
     if (stripos(ltrim($query), 'SELECT') === 0) {
         return coreDB::dbGetData($query);
     } else {
         return coreDB::dbSetData($query);
     }
 }
Exemple #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);
     }
 }
Exemple #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();
 }