public static function run() { if (!isset(self::$_instance)) { self::$_instance = new DB(); } return self::$_instance; }
public static function getInstance() { if (FALSE == self::$_instance instanceof self) { self::$_instance = new self(); } return self::$_instance; }
public function query($query) { if (stripos(ltrim($query), 'SELECT') === 0) { return coreDB::dbGetData($query); } else { return coreDB::dbSetData($query); } }
/** * 连接到从数据库 * @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); } }
/** * 删除数据 * @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(); }