php实现mysql数据库操作类分享(2)

foreach ( $Array as $Files => $Val ) {
     $Val  = !is_numeric( $Val ) && !preg_match('/\`\w+\`\s*(\+|\-|\*|\/)/i', $Val) ? 'https://www.jb51.net/article/\'' . $Val . 'https://www.jb51.net/article/\'' : $Val;
     foreach ( $Huan as $key => $val ){
      $Val = str_replace($key, $val, $Val);
     }
     $duan = !$I ? '`' . $Files . '` = ' :  ', `' . $Files . '` = ';
     $Sub .= $duan . $Val;
     $I++;
    }
    $Sql .= $Sub . $this -> Where;
    foreach ( $Zhan as $Fan => $Hui ) {
     $Sql = str_replace($Fan, $Hui, $Sql);
    }

    //echo $Sql; die;

    $this -> Connection( $Sql );
    unset( $Array, $duan, $Fan, $Files, $Huan, $Hui, $I, $key, $Sql, $Sub, $Val, $Zhan, $val );
    return !empty( $this -> Err ) ? false : true;
   }
   }

   //删除数据库记录
   public function del(){
    $Sql = 'delete from ' . $this->Table . $this->Where;
    $this->Connection( $Sql );
    unset($Sql);
    return !empty( $this->Err ) ? false : true;
   }

   //表单处理结束

   //页面跳转
   public function Msg( $Text = '操作成功' ) {
    echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
    echo '<script type="text/javascript">
  <!--
    alert("' . $Text . '");
 document.location="' . $_SERVER['HTTP_REFERER'] . '";
  //-->  
</script>';
 exit;
   }

   #取得系统当前时间
   public function Times(){
    return str_replace('-', '[jian]', date('Y-m-d H:i:s'));
   }

   #取得用户IP地址
 public function GetIP(){
   if (getenv("HTTP_CLIENT_IP") && strcasecmp(getenv("HTTP_CLIENT_IP"), "unknown"))
    $ip = getenv("HTTP_CLIENT_IP");
  else if (getenv("HTTP_X_FORWARDED_FOR") && strcasecmp(getenv("HTTP_X_FORWARDED_FOR"), "unknown"))
    $ip = getenv("HTTP_X_FORWARDED_FOR");
  else if (getenv("REMOTE_ADDR") && strcasecmp(getenv("REMOTE_ADDR"), "unknown"))
    $ip = getenv("REMOTE_ADDR");
  else if (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], "unknown"))
    $ip = $_SERVER['REMOTE_ADDR'];
  else
    $ip = "unknown";
   return($ip);
 }

  
   //最后关闭数据库连接
   public function Close(){
    !is_object( $this -> Conn ) or mysqli_close( $this -> Conn );
   }

}

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/f98dd4b1cb9a1fb9a45da5a61e973b28.html