찾다
php教程php手册实战PHP第一天
实战PHP第一天Jun 13, 2016 am 10:56 AM
headerphpt실제 전투브라우저첫날코딩설정

今天我学到了

php发送给浏览器设置编码

header('content-type:text/html;charset=utf-8');

 


smarty模板引擎在类里面会报N多错

 


brophp里的DB类,我修改了也无法单独使用

 


thinkphp里的DB类,我修改了也是不能单独使用.

 


最后使用了 网上开源的 mysql类


[php]
// +----------------------------------------------------------------------  
// |MySQL操作类  
// +----------------------------------------------------------------------  
// |@微凉 QQ:496928838  
// +----------------------------------------------------------------------  
class MySQL{ 
     
    private $db_mysql_hostname; 
    private $db_mysql_username; 
    private $db_mysql_password; 
    private $db_mysql_database; 
    private $db_mysql_port; 
    private $db_mysql_charset; 
     
    private $query_list = array(); 
     
    //查询次数  
    public $query_count = 0; 
    //查询开始时间  
    public $query_start_time; 
     
    //当前查询ID  
    protected $queryID; 
    //当前连接  
    protected $conn; 
    // 事务指令数  
    protected $transTimes = 0; 
    // 返回或者影响记录数  
    protected $numRows    = 0; 
    // 错误信息  
    protected $error      = ''; 
     
    public function __construct($hostname_or_conf,$username,$password,$database,$port = '3306',$char = 'utf8'){ 
        if(is_array($hostname_or_conf)){ 
            $this->db_mysql_hostname = $hostname_or_conf['hostname']; 
            $this->db_mysql_username = $hostname_or_conf['username']; 
            $this->db_mysql_password = $hostname_or_conf['password']; 
            $this->db_mysql_database = $hostname_or_conf['database']; 
            $this->db_mysql_port = isset($hostname_or_conf['port'])?$hostname_or_conf['port']:'3306'; 
            $this->db_mysql_charset = isset($hostname_or_conf['charset'])?$hostname_or_conf['charset']:'utf8'; 
             
        }elseif(!empty($hostname_or_conf)||!empty($username)||!empty($password)||!empty($database)) 
        { 
             $this->db_mysql_hostname = $hostname_or_conf; 
             $this->db_mysql_username = $username; 
             $this->db_mysql_password = $password; 
             $this->db_mysql_database = $database; 
             $this->db_mysql_port = $port; 
             $this->db_mysql_charset = $char; 
              
        }else{ 
            die('configuration error.'); 
        } 
        $this->connect(); 
    } 
     
    private function connect(){ 
        $server = $this->db_mysql_hostname.':'.$this->db_mysql_port; 
        $this->conn = mysql_connect($server,$this->db_mysql_username,$this->db_mysql_password,true) or die('Connect MySQL DB error!'); 
        mysql_select_db($this->db_mysql_database,$this->conn) or die('select db error!'); 
        mysql_query("set names " . $this->db_mysql_charset, $this->conn); 
    } 
    /**
     +----------------------------------------------------------
     * 设置数据对象值
     +----------------------------------------------------------
     * @access public
     +----------------------------------------------------------
     *table,where,order,limit,data,field,join,group,having
     +----------------------------------------------------------
     */ 
    public function table($table){ 
        $this->query_list['table'] = $table; 
        return $this; 
    } 
     
    public function where($where){ 
        $this->query_list['where'] = $where; 
        return $this; 
    } 
     
    public function order($order){ 
        $this->query_list['order'] = $order; 
        return $this; 
    } 
     
    public function limit($offset,$length){ 
        if(!isset($length)){ 
            $length = $offset; 
            $offset = 0; 
        } 
        $this->query_list['limit'] = 'limit '.$offset.','.$length; 
        return $this; 
    } 
     
    public function data($data){ 
        /*
        if(is_object($data)){
            $data   =   get_object_vars($data);
        }elseif (is_string($data)){
            parse_str($data,$data);
        }elseif(!is_array($data)){
            //Log:DATA_TYPE_INVALID
        }
        */ 
        $this->query_list['data'] = $data; 
        return $this; 
    } 
    public function field($fields){ 
        $this->query_list['fields'] = $fields; 
        return $this; 
    } 
    public function join($join){ 
        $this->query_list['join'] = $join; 
        return $this; 
    } 
    public function group($group){ 
        $this->query_list['group'] = $group; 
        return $this; 
    } 
    public function having($having){ 
        $this->query_list['having'] = $having; 
        return $this; 
    } 
    /**
     +----------------------------------------------------------
     * 查询
     +----------------------------------------------------------
     * @access public
     +----------------------------------------------------------
     * @param 
     +----------------------------------------------------------
     */ 
    public function select(){ 
        $select_sql = 'select '; 
        $fields = isset($this->query_list['fields'])?$this->query_list['fields']:'*'; 
        $select_sql.=$fields; 
        $select_sql.= ' from `'.$this->query_list['table'].'` '; 
         
        isset($this->query_list['join'])?($select_sql.=$this->query_list['join']):''; 
        isset($this->query_list['where'])?($select_sql.=' where '.$this->query_list['where']):''; 
        isset($this->query_list['group'])?($select_sql.=' group by'.$this->query_list['group']):''; 
        isset($this->query_list['having'])?($select_sql.=' mysql having '.$this->query_list['having']):''; 
        isset($this->query_list['order'])?($select_sql.=' order by '.$this->query_list['order']):''; 
        isset($this->query_list['limit'])?($select_sql.=' '.$this->query_list['limit']):''; 
         
        return $this->query($select_sql); 
    } 
    /**
     +----------------------------------------------------------
     * 增加
     +----------------------------------------------------------
     * @access public
     +----------------------------------------------------------
     * @param 
     +----------------------------------------------------------
     */ 
    public function add(){ 
        $add_sql = 'insert into `'.$this->query_list['table'].'` ('; 
         
        $data = $this->query_list['data']; 
        $value = $field = ''; 
        foreach($data as $k=>$v){ 
            $field .= '`'.$k.'`,'; 
            if(is_numeric($v)) 
                $value .= $v.','; 
            else 
                $value .= '\''.$v.'\','; 
        } 
        $add_sql .= rtrim($field,',').') values ('.rtrim($value,',').')'; 
 
        return $this->execute($add_sql); 
    } 
    /**
     +----------------------------------------------------------
     * 删除
     +----------------------------------------------------------
     * @access public
     +----------------------------------------------------------
     * @param 
     +----------------------------------------------------------
     */ 
    public function delete(){ 
        $del_sql = 'delete from `'.$this->query_list['table'].'` where '.$this->query_list['where']; 
         
        if(isset($this->query_list['order'])) 
            $del_sql .= 'order by '.$this->query_list['order']; 
        if(isset($this->query_list['limit'])) 
            $del_sql .= ' '.$this->query_list['limit']; 
             
        return $this->execute($del_sql); 
         
    } 
    /**
     +----------------------------------------------------------
     * 更新
     +----------------------------------------------------------
     * @access public
     +----------------------------------------------------------
     * @param 
     +----------------------------------------------------------
     */ 
    public function update(){ 
        $update_sql = 'update `'.$this->query_list['table'].'` set '; 
        $data = $this->query_list['data']; 
         
        foreach($data as $k=>$v){ 
            if(is_numeric($v)) 
                $update_sql .= '`'.$k.'` ='.$v.','; 
            else 
                $update_sql .= '`'.$k.'` =\''.$v.'\','; 
        } 
        $update_sql = rtrim($update_sql,','); 
        if(isset($this->query_list['where'])) 
            $update_sql .= ' where '.$this->query_list['where']; 
        if(isset($this->query_list['order'])) 
            $update_sql .= ' order by '.$this->query_list['order']; 
        if(isset($this->query_list['limit'])) 
            $update_sql .= ' '.$this->query_list['limit']; 
         
        return $this->execute($update_sql); 
         
    } 
     /**
     +----------------------------------------------------------
     * 执行查询 返回数据集
     +----------------------------------------------------------
     * @access public
     +----------------------------------------------------------
     * @param string $sql  sql指令
     */ 
    public function query($sql) { 
        if ( !$this->conn ) return false; 
        $this->queryStr = $sql; 
        //释放前次的查询结果  
        if ( $this->queryID ) {    $this->free();    } 
         
        $this->query_start_time = microtime(true); 
         
        $this->queryID = mysql_query($sql, $this->conn); 
        $this->query_count++; 
        if ( false === $this->queryID ) { 
            $this->error(); 
            return false; 
        } else { 
            $this->numRows = mysql_num_rows($this->queryID); 
            return $this->getAll(); 
        } 
    } 
    /**
     +----------------------------------------------------------
     * 执行语句
     +----------------------------------------------------------
     * @access public
     +----------------------------------------------------------
     * @param string $sql  sql指令
     +----------------------------------------------------------
     */ 
    public function execute($sql) { 
        if ( !$this->conn ) return false; 
        $this->queryStr = $sql; 
        //释放前次的查询结果  
        if ( $this->queryID ) {    $this->free();    } 
         
        $this->query_start_time = microtime(true); 
         
        $result =   mysql_query($sql, $this->conn) ; 
        $this->query_count++; 
        if ( false === $result) { 
            $this->error(); 
            return false; 
        } else { 
            $this->numRows = mysql_affected_rows($this->conn); 
            return $this->numRows; 
        } 
    } 
    /**
     +----------------------------------------------------------
     * 获得所有的查询数据
     +----------------------------------------------------------
     * @access private
     +----------------------------------------------------------
     * @return array
     */ 
    private function getAll() { 
        //返回数据集  
        $result = array(); 
        if($this->numRows >0) { 
            while($row = mysql_fetch_assoc($this->queryID)){ 
                $result[]   =   $row; 
            } 
            mysql_data_seek($this->queryID,0); 
        } 
        return $result; 
    } 
    /**
     +----------------------------------------------------------
     * 取得数据表的字段信息
     +----------------------------------------------------------
     * @access public
     +----------------------------------------------------------
     */ 
    public function getFields($tableName) { 
        $result =   $this->query('SHOW COLUMNS FROM `'.$tableName.'`'); 
        $info   =   array(); 
        if($result) { 
            foreach ($result as $key => $val) { 
                $info[$val['Field']] = array( 
                    'name'    => $val['Field'], 
                    'type'    => $val['Type'], 
                    'notnull' => (bool) ($val['Null'] === ''), // not null is empty, null is yes  
                    'default' => $val['Default'], 
                    'primary' => (strtolower($val['Key']) == 'pri'), 
                    'autoinc' => (strtolower($val['Extra']) == 'auto_increment'), 
                ); 
            } 
        } 
        return $info; 
    } 
    /**
     +----------------------------------------------------------
     * 取得数据库的表信息
     +----------------------------------------------------------
     * @access public
     +----------------------------------------------------------
     */ 
    public function getTables($dbName='') { 
        if(!empty($dbName)) { 
           $sql    = 'SHOW TABLES FROM '.$dbName; 
        }else{ 
           $sql    = 'SHOW TABLES '; 
        } 
        $result =   $this->query($sql); 
        $info   =   array(); 
        foreach ($result as $key => $val) { 
            $info[$key] = current($val); 
        } 
        return $info; 
    } 
 
    /**
     +----------------------------------------------------------
     * 最后次操作的ID
     +----------------------------------------------------------
     * @access public
     +----------------------------------------------------------
     * @param 
     +----------------------------------------------------------
     */ 
     public function last_insert_id(){ 
        return mysql_insert_id($this->conn); 
    } 
    /**
     * 执行一条带有结果集计数的
     */ 
    public function count($sql){ 
        return $this->execute($sql); 
    } 
    /**
     +----------------------------------------------------------
     * 启动事务
     +----------------------------------------------------------
     * @access public
     +----------------------------------------------------------
     * @return void
     +----------------------------------------------------------
     */ 
    public function startTrans() { 
        if ($this->transTimes == 0) { 
            mysql_query('START TRANSACTION', $this->conn); 
        } 
        $this->transTimes++; 
        return ; 
    } 
 
    /**
     +----------------------------------------------------------
     * 提交事务
     +----------------------------------------------------------
     * @access public
     +----------------------------------------------------------
     * @return boolen
     +----------------------------------------------------------
     */ 
    public function commit() 
    { 
        if ($this->transTimes > 0) { 
            $result = mysql_query('COMMIT', $this->conn); 
            $this->transTimes = 0; 
            if(!$result){ 
                throw new Exception($this->error()); 
            } 
        } 
        return true; 
    } 
 
    /**
     +----------------------------------------------------------
     * 事务回滚
     +----------------------------------------------------------
     * @access public
     +----------------------------------------------------------
     * @return boolen
     +----------------------------------------------------------
     */ 
    public function rollback() 
    { 
        if ($this->transTimes > 0) { 
            $result = mysql_query('ROLLBACK', $this->conn); 
            $this->transTimes = 0; 
            if(!$result){ 
                throw new Exception($this->error()); 
            } 
        } 
        return true; 
    } 
    /**
     +----------------------------------------------------------
     * 错误信息
     +----------------------------------------------------------
     * @access public
     +----------------------------------------------------------
     * @param 
     +----------------------------------------------------------
     */ 
     public function error() { 
        $this->error = mysql_error($this->conn); 
        if('' != $this->queryStr){ 
            $this->error .= "\n [ SQL语句 ] : ".$this->queryStr; 
        } 
        return $this->error; 
    } 
    /**
     +----------------------------------------------------------
     * 释放查询结果
     +----------------------------------------------------------
     * @access public
     +----------------------------------------------------------
     */ 
    public function free() { 
        @mysql_free_result($this->queryID); 
        $this->queryID = 0; 
        $this->query_list = null; 
    } 
    /**
     +----------------------------------------------------------
     * 关闭连接
     +----------------------------------------------------------
     * @access public
     +----------------------------------------------------------
     * @param 
     +----------------------------------------------------------
     */ 
    function close(){ 
        if ($this->conn && !mysql_close($this->conn)){ 
            throw new Exception($this->error()); 
        } 
        $this->conn = 0; 
        $this->query_count = 0; 
    } 
    /**
     +----------------------------------------------------------
     * 析构方法
     +----------------------------------------------------------
     * @access public
     +----------------------------------------------------------
     */ 
    function __destruct(){ 
         $this->close(); 
    } 

// +----------------------------------------------------------------------
// |MySQL操作类
// +----------------------------------------------------------------------
// |@微凉 QQ:496928838
// +----------------------------------------------------------------------
class MySQL{
 
 private $db_mysql_hostname;
 private $db_mysql_username;
 private $db_mysql_password;
 private $db_mysql_database;
 private $db_mysql_port;
 private $db_mysql_charset;
 
 private $query_list = array();
 
 //查询次数
 public $query_count = 0;
 //查询开始时间
 public $query_start_time;
 
 //当前查询ID
 protected $queryID;
 //当前连接
 protected $conn;
 // 事务指令数
 protected $transTimes = 0;
 // 返回或者影响记录数
    protected $numRows    = 0;
    // 错误信息
    protected $error      = '';
 
 public function __construct($hostname_or_conf,$username,$password,$database,$port = '3306',$char = 'utf8'){
  if(is_array($hostname_or_conf)){
   $this->db_mysql_hostname = $hostname_or_conf['hostname'];
   $this->db_mysql_username = $hostname_or_conf['username'];
   $this->db_mysql_password = $hostname_or_conf['password'];
   $this->db_mysql_database = $hostname_or_conf['database'];
   $this->db_mysql_port = isset($hostname_or_conf['port'])?$hostname_or_conf['port']:'3306';
   $this->db_mysql_charset = isset($hostname_or_conf['charset'])?$hostname_or_conf['charset']:'utf8';
   
  }elseif(!empty($hostname_or_conf)||!empty($username)||!empty($password)||!empty($database))
  {
    $this->db_mysql_hostname = $hostname_or_conf;
      $this->db_mysql_username = $username;
      $this->db_mysql_password = $password;
     $this->db_mysql_database = $database;
    $this->db_mysql_port = $port;
    $this->db_mysql_charset = $char;
   
  }else{
   die('configuration error.');
  }
       $this->connect();
    }
 
 private function connect(){
  $server = $this->db_mysql_hostname.':'.$this->db_mysql_port;
  $this->conn = mysql_connect($server,$this->db_mysql_username,$this->db_mysql_password,true) or die('Connect MySQL DB error!');
  mysql_select_db($this->db_mysql_database,$this->conn) or die('select db error!');
  mysql_query("set names " . $this->db_mysql_charset, $this->conn);
 }
 /**
     +----------------------------------------------------------
     * 设置数据对象值
     +----------------------------------------------------------
     * @access public
     +----------------------------------------------------------
     *table,where,order,limit,data,field,join,group,having
     +----------------------------------------------------------
     */
 public function table($table){
  $this->query_list['table'] = $table;
  return $this;
 }
 
 public function where($where){
  $this->query_list['where'] = $where;
  return $this;
 }
 
 public function order($order){
  $this->query_list['order'] = $order;
  return $this;
 }
 
 public function limit($offset,$length){
  if(!isset($length)){
   $length = $offset;
   $offset = 0;
  }
  $this->query_list['limit'] = 'limit '.$offset.','.$length;
  return $this;
 }
 
 public function data($data){
  /*
  if(is_object($data)){
   $data   =   get_object_vars($data);
  }elseif (is_string($data)){
   parse_str($data,$data);
  }elseif(!is_array($data)){
   //Log:DATA_TYPE_INVALID
  }
  */
  $this->query_list['data'] = $data;
  return $this;
 }
 public function field($fields){
  $this->query_list['fields'] = $fields;
  return $this;
 }
 public function join($join){
  $this->query_list['join'] = $join;
  return $this;
 }
 public function group($group){
  $this->query_list['group'] = $group;
  return $this;
 }
 public function having($having){
  $this->query_list['having'] = $having;
  return $this;
 }
 /**
     +----------------------------------------------------------
     * 查询
     +----------------------------------------------------------
     * @access public
     +----------------------------------------------------------
     * @param
     +----------------------------------------------------------
     */
 public function select(){
  $select_sql = 'select ';
  $fields = isset($this->query_list['fields'])?$this->query_list['fields']:'*';
  $select_sql.=$fields;
  $select_sql.= ' from `'.$this->query_list['table'].'` ';
  
  isset($this->query_list['join'])?($select_sql.=$this->query_list['join']):'';
  isset($this->query_list['where'])?($select_sql.=' where '.$this->query_list['where']):'';
  isset($this->query_list['group'])?($select_sql.=' group by'.$this->query_list['group']):'';
  isset($this->query_list['having'])?($select_sql.=' mysql having '.$this->query_list['having']):'';
  isset($this->query_list['order'])?($select_sql.=' order by '.$this->query_list['order']):'';
  isset($this->query_list['limit'])?($select_sql.=' '.$this->query_list['limit']):'';
  
  return $this->query($select_sql);
 }
 /**
     +----------------------------------------------------------
     * 增加
     +----------------------------------------------------------
     * @access public
     +----------------------------------------------------------
     * @param
     +----------------------------------------------------------
     */
 public function add(){
  $add_sql = 'insert into `'.$this->query_list['table'].'` (';
  
  $data = $this->query_list['data'];
  $value = $field = '';
  foreach($data as $k=>$v){
   $field .= '`'.$k.'`,';
   if(is_numeric($v))
    $value .= $v.',';
   else
    $value .= '\''.$v.'\',';
  }
  $add_sql .= rtrim($field,',').') values ('.rtrim($value,',').')';

  return $this->execute($add_sql);
 }
 /**
     +----------------------------------------------------------
     * 删除
     +----------------------------------------------------------
     * @access public
     +----------------------------------------------------------
     * @param
     +----------------------------------------------------------
     */
 public function delete(){
  $del_sql = 'delete from `'.$this->query_list['table'].'` where '.$this->query_list['where'];
  
  if(isset($this->query_list['order']))
   $del_sql .= 'order by '.$this->query_list['order'];
  if(isset($this->query_list['limit']))
   $del_sql .= ' '.$this->query_list['limit'];
   
  return $this->execute($del_sql);
  
 }
 /**
     +----------------------------------------------------------
     * 更新
     +----------------------------------------------------------
     * @access public
     +----------------------------------------------------------
     * @param
     +----------------------------------------------------------
     */
 public function update(){
  $update_sql = 'update `'.$this->query_list['table'].'` set ';
  $data = $this->query_list['data'];
  
  foreach($data as $k=>$v){
   if(is_numeric($v))
    $update_sql .= '`'.$k.'` ='.$v.',';
   else
    $update_sql .= '`'.$k.'` =\''.$v.'\',';
  }
  $update_sql = rtrim($update_sql,',');
  if(isset($this->query_list['where']))
   $update_sql .= ' where '.$this->query_list['where'];
  if(isset($this->query_list['order']))
   $update_sql .= ' order by '.$this->query_list['order'];
  if(isset($this->query_list['limit']))
   $update_sql .= ' '.$this->query_list['limit'];
  
  return $this->execute($update_sql);
  
 }
  /**
     +----------------------------------------------------------
     * 执行查询 返回数据集
     +----------------------------------------------------------
     * @access public
     +----------------------------------------------------------
     * @param string $sql  sql指令
     */
    public function query($sql) {
        if ( !$this->conn ) return false;
        $this->queryStr = $sql;
        //释放前次的查询结果
        if ( $this->queryID ) {    $this->free();    }
       
        $this->query_start_time = microtime(true);
       
        $this->queryID = mysql_query($sql, $this->conn);
        $this->query_count++;
        if ( false === $this->queryID ) {
            $this->error();
            return false;
        } else {
            $this->numRows = mysql_num_rows($this->queryID);
            return $this->getAll();
        }
    }
 /**
     +----------------------------------------------------------
     * 执行语句
     +----------------------------------------------------------
     * @access public
     +----------------------------------------------------------
     * @param string $sql  sql指令
     +----------------------------------------------------------
     */
    public function execute($sql) {
        if ( !$this->conn ) return false;
        $this->queryStr = $sql;
        //释放前次的查询结果
        if ( $this->queryID ) {    $this->free();    }
       
        $this->query_start_time = microtime(true);
       
        $result =   mysql_query($sql, $this->conn) ;
        $this->query_count++;
        if ( false === $result) {
            $this->error();
            return false;
        } else {
            $this->numRows = mysql_affected_rows($this->conn);
            return $this->numRows;
        }
    }
 /**
     +----------------------------------------------------------
     * 获得所有的查询数据
     +----------------------------------------------------------
     * @access private
     +----------------------------------------------------------
     * @return array
     */
    private function getAll() {
        //返回数据集
        $result = array();
        if($this->numRows >0) {
            while($row = mysql_fetch_assoc($this->queryID)){
                $result[]   =   $row;
            }
            mysql_data_seek($this->queryID,0);
        }
        return $result;
    }
 /**
     +----------------------------------------------------------
     * 取得数据表的字段信息
     +----------------------------------------------------------
     * @access public
     +----------------------------------------------------------
     */
    public function getFields($tableName) {
        $result =   $this->query('SHOW COLUMNS FROM `'.$tableName.'`');
        $info   =   array();
        if($result) {
            foreach ($result as $key => $val) {
                $info[$val['Field']] = array(
                    'name'    => $val['Field'],
                    'type'    => $val['Type'],
                    'notnull' => (bool) ($val['Null'] === ''), // not null is empty, null is yes
                    'default' => $val['Default'],
                    'primary' => (strtolower($val['Key']) == 'pri'),
                    'autoinc' => (strtolower($val['Extra']) == 'auto_increment'),
                );
            }
        }
        return $info;
    }
 /**
     +----------------------------------------------------------
     * 取得数据库的表信息
     +----------------------------------------------------------
     * @access public
     +----------------------------------------------------------
     */
    public function getTables($dbName='') {
        if(!empty($dbName)) {
           $sql    = 'SHOW TABLES FROM '.$dbName;
        }else{
           $sql    = 'SHOW TABLES ';
        }
        $result =   $this->query($sql);
        $info   =   array();
        foreach ($result as $key => $val) {
            $info[$key] = current($val);
        }
        return $info;
    }

 /**
     +----------------------------------------------------------
     * 最后次操作的ID
     +----------------------------------------------------------
     * @access public
     +----------------------------------------------------------
     * @param
     +----------------------------------------------------------
     */
  public function last_insert_id(){
        return mysql_insert_id($this->conn);
    }
    /**
     * 执行一条带有结果集计数的
     */
    public function count($sql){
        return $this->execute($sql);
    }
 /**
     +----------------------------------------------------------
     * 启动事务
     +----------------------------------------------------------
     * @access public
     +----------------------------------------------------------
     * @return void
     +----------------------------------------------------------
     */
    public function startTrans() {
        if ($this->transTimes == 0) {
            mysql_query('START TRANSACTION', $this->conn);
        }
        $this->transTimes++;
        return ;
    }

    /**
     +----------------------------------------------------------
     * 提交事务
     +----------------------------------------------------------
     * @access public
     +----------------------------------------------------------
     * @return boolen
     +----------------------------------------------------------
     */
    public function commit()
    {
        if ($this->transTimes > 0) {
            $result = mysql_query('COMMIT', $this->conn);
            $this->transTimes = 0;
            if(!$result){
                throw new Exception($this->error());
            }
        }
        return true;
    }

    /**
     +----------------------------------------------------------
     * 事务回滚
     +----------------------------------------------------------
     * @access public
     +----------------------------------------------------------
     * @return boolen
     +----------------------------------------------------------
     */
    public function rollback()
    {
        if ($this->transTimes > 0) {
            $result = mysql_query('ROLLBACK', $this->conn);
            $this->transTimes = 0;
            if(!$result){
                throw new Exception($this->error());
            }
        }
        return true;
    }
 /**
     +----------------------------------------------------------
     * 错误信息
     +----------------------------------------------------------
     * @access public
     +----------------------------------------------------------
     * @param
     +----------------------------------------------------------
     */
  public function error() {
        $this->error = mysql_error($this->conn);
        if('' != $this->queryStr){
            $this->error .= "\n [ SQL语句 ] : ".$this->queryStr;
        }
        return $this->error;
    }
 /**
     +----------------------------------------------------------
     * 释放查询结果
     +----------------------------------------------------------
     * @access public
     +----------------------------------------------------------
     */
    public function free() {
        @mysql_free_result($this->queryID);
        $this->queryID = 0;
        $this->query_list = null;
    }
    /**

성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
手把手教你uniapp和小程序分包(图文)手把手教你uniapp和小程序分包(图文)Jul 22, 2022 pm 04:55 PM

本篇文章给大家带来了关于uniapp跨域的相关知识,其中介绍了uniapp和小程序分包的相关问题,每个使用分包小程序必定含有一个主包。所谓的主包,即放置默认启动页面/TabBar 页面,以及一些所有分包都需用到公共资源/JS 脚本;而分包则是根据开发者的配置进行划分,希望对大家有帮助。

MySQL表设计实战:创建一个电商订单表和商品评论表MySQL表设计实战:创建一个电商订单表和商品评论表Jul 03, 2023 am 08:07 AM

MySQL表设计实战:创建一个电商订单表和商品评论表在电商平台的数据库中,订单表和商品评论表是两个非常重要的表格。本文将介绍如何使用MySQL来设计和创建这两个表格,并给出代码示例。一、订单表的设计与创建订单表用于存储用户的购买信息,包括订单号、用户ID、商品ID、购买数量、订单状态等字段。首先,我们需要创建一个名为"order"的表格,使用CREATET

Java开发实战:集成七牛云云存储服务实现文件上传Java开发实战:集成七牛云云存储服务实现文件上传Jul 06, 2023 pm 06:22 PM

Java开发实战:集成七牛云云存储服务实现文件上传引言随着云计算和云存储的发展,越来越多的应用程序需要将文件上传至云端进行存储和管理。云存储服务的优势在于高可靠性、可扩展性和灵活性。本文将介绍如何使用Java语言开发,集成七牛云云存储服务,实现文件上传功能。七牛云简介七牛云是国内领先的云存储服务提供商,其提供了全面的云存储和内容分发服务。用户可以通过七牛云提

Golang实战:数据导出功能的实现技巧分享Golang实战:数据导出功能的实现技巧分享Feb 29, 2024 am 09:00 AM

数据导出功能在实际开发中是非常常见的需求,特别是在后台管理系统或者数据报表导出等场景中。本文将以Golang语言为例,分享数据导出功能的实现技巧,并给出具体的代码示例。1.环境准备在开始之前,确保已经安装好Golang环境,并且熟悉Golang的基本语法和操作。另外,为了实现数据导出功能,可能还需要使用第三方库,比如github.com/360EntSec

深入学习 Elasticsearch 查询语法与实战深入学习 Elasticsearch 查询语法与实战Oct 03, 2023 am 08:42 AM

深入学习Elasticsearch查询语法与实战引言:Elasticsearch是一款基于Lucene的开源搜索引擎,主要用于分布式搜索与分析,广泛应用于大规模数据的全文搜索、日志分析、推荐系统等场景。在使用Elasticsearch进行数据查询时,灵活运用查询语法是提高查询效率的关键。本文将深入探讨Elasticsearch查询语法,并结合实际案例给出

Vue实战:日期选择器组件开发Vue实战:日期选择器组件开发Nov 24, 2023 am 09:03 AM

Vue实战:日期选择器组件开发引言:日期选择器是在日常开发中经常用到的一个组件,它可以方便地选择日期,并提供各种配置选项。本文将介绍如何使用Vue框架来开发一个简单的日期选择器组件,并提供具体的代码示例。一、需求分析在开始开发之前,我们需要进行需求分析,明确组件的功能和特性。根据常见的日期选择器组件功能,我们需要实现以下几个功能点:基础功能:能够选择日期,并

MySQL表设计实战:创建一个电影信息表和演员表MySQL表设计实战:创建一个电影信息表和演员表Jul 01, 2023 pm 08:16 PM

MySQL表设计实战:创建一个电影信息表和演员表导语:在数据库设计中,表的创建是一个非常关键的环节。本文将以电影信息表和演员表为例,详细介绍如何进行MySQL表的设计和创建,并附上相应的代码示例。一、电影信息表设计和创建电影信息表是用来存储电影的相关信息,包括电影名称、导演、上映时间、电影类型等字段。下面是电影信息表的设计和创建过程,首先我们需要选择合适的字

Git开发实战:项目经验分享与总结Git开发实战:项目经验分享与总结Nov 04, 2023 pm 12:32 PM

Git是一款分布式版本控制系统,广泛应用于软件开发领域。在实际的项目开发中,合理利用Git进行团队协作和版本管理,能够极大地提高开发效率和项目质量。本文将分享我在Git开发中的实战经验,并总结一些注意事项和技巧,希望对读者有所启发和帮助。一、团队协作之分支管理在多人协作的项目中,充分利用Git的分支管理功能,能够更好地进行团队协作和版本控制。通常情况下,主干

See all articles

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover

AI Clothes Remover

사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

AI Hentai Generator

AI Hentai Generator

AI Hentai를 무료로 생성하십시오.

뜨거운 도구

SublimeText3 영어 버전

SublimeText3 영어 버전

권장 사항: Win 버전, 코드 프롬프트 지원!

맨티스BT

맨티스BT

Mantis는 제품 결함 추적을 돕기 위해 설계된 배포하기 쉬운 웹 기반 결함 추적 도구입니다. PHP, MySQL 및 웹 서버가 필요합니다. 데모 및 호스팅 서비스를 확인해 보세요.

Atom Editor Mac 버전 다운로드

Atom Editor Mac 버전 다운로드

가장 인기 있는 오픈 소스 편집기

메모장++7.3.1

메모장++7.3.1

사용하기 쉬운 무료 코드 편집기

SublimeText3 Mac 버전

SublimeText3 Mac 버전

신 수준의 코드 편집 소프트웨어(SublimeText3)