zoukankan      html  css  js  c++  java
  • 我的DBDA类文件

    <?php
    class DBDA
    {
        public $host = "localhost";
        public $uid = "root";
        public $pwd = "root";
        public $dbname = "mydb";
        
        public function Query($sql,$type=1)
        {
            $db = new MySQLi($this->host,$this->uid,$this->pwd,$this->dbname);
            $result = $db->query($sql);
            
            if($type=="1")
            {
                return $result->fetch_all();
            }
            else
            {
                return $result;
            }
        }
        
        public function StrQuery($sql,$type=1)
        {
            $db = new MySQLi($this->host,$this->uid,$this->pwd,$this->dbname);
            $result = $db->query($sql);
            
            if($type=="1")
            {
                $arr = $result->fetch_all();
                $str = "";
                foreach($arr as $v)
                {
                    $str = $str.implode("^",$v)."|";
                }
                $str = substr($str,0,strlen($str)-1);
                return  $str;
            }
            else
            {
                return $result;
            }
        }
        
        public function JsonQuery($sql,$type=1)
        {
            $db = new MySQLi($this->host,$this->uid,$this->pwd,$this->dbname);
            $result = $db->query($sql);
            
            if($type=="1")
            {
                $arr = $result->fetch_all(MYSQLI_ASSOC);
                return json_encode($arr);
            }
            else
            {
                return $result;
            }
        }
    }
  • 相关阅读:
    JNday7-pm
    JNday7-am
    bzoj1047理想的正方形
    关于OI中简单的常数优化
    bzoj1050旅行
    bzoj1044木棍分割
    bzoj1875 HH去散步
    bzoj1059矩阵游戏
    bzoj2705Longge的问题
    bzoj1833数字计数
  • 原文地址:https://www.cnblogs.com/yyy251/p/6794816.html
Copyright © 2011-2022 走看看