中文字幕在线观看,亚洲а∨天堂久久精品9966,亚洲成a人片在线观看你懂的,亚洲av成人片无码网站,亚洲国产精品无码久久久五月天

php數(shù)據(jù)處理公共類

2018-07-20    來源:open-open

容器云強勢上線!快速搭建集群,上萬Linux鏡像隨意使用
    <?php  
        /*==================================================================*/  
        /*      文件名:BaseLogic.class.php                          */  
        /*      概要: 數(shù)據(jù)處理公共類.                                */  
      
        class BaseLogic extends MyDB {  
            protected $tabName;     //表的名稱  
            protected $fieldList;   //字段集合  
            protected $messList;  
      
            //==========================================  
            // 函數(shù): add($postList)  
            // 功能: 添加  
            // 參數(shù): $postList 提交的變量列表  
            // 返回: 剛插入的自增ID  
            //==========================================  
            function add($postList) {  
                $fieldList='';  
                $value='';  
                foreach ($postList as $k=>$v) {  
                    if(in_array($k, $this->fieldList)){  
                        $fieldList.=$k.",";  
                        if (!get_magic_quotes_gpc())  
                            $value .= "'".addslashes($v)."',";  
                        else  
                            $value .= "'".$v."',";  
                    }  
                }  
      
                $fieldList=rtrim($fieldList, ",");  
                $value=rtrim($value, ",");  
      
                $sql = "INSERT INTO {$this->tabName} (".$fieldList.") VALUES(".$value.")";  
                echo $sql;  
                $result=$this->mysqli->query($sql);  
                if($result && $this->mysqli->affected_rows >0 )   
                    return $this->mysqli->insert_id;  
                else  
                    return false;  
            }  
      
      
            //==========================================  
            // 函數(shù): mod($postList)  
            // 功能: 修改表數(shù)據(jù)  
            // 參數(shù): $postList 提交的變量列表  
            //==========================================  
            function mod($postList) {  
                $id=$postList["id"];  
                unset($postList["id"]);  
                $value='';  
                foreach ($postList as $k=>$v) {  
                    if(in_array($k, $this->fieldList)){  
                        if (!get_magic_quotes_gpc())  
                            $value .= $k." = '".addslashes($v)."',";  
                        else  
                            $value .= $k." = '".$v."',";  
                    }  
                }  
                $value=rtrim($value, ",");  
                $sql = "UPDATE {$this->tabName} SET {$value} WHERE id={$id}";  
                return $this->mysqli->query($sql);      
            }  
          
            //==========================================  
            // 函數(shù): del($id)  
            // 功能: 刪除  
            // 參數(shù): $id 編號或ID列表數(shù)組  
            // 返回: 0 失敗 成功為刪除的記錄數(shù)  
            //==========================================  
            function del($id) {  
                if(is_array($id))  
                    $tmp = "IN (" . join(",", $id) . ")";  
                else   
                    $tmp = "= $id";  
                  
                $sql = "DELETE FROM {$this->tabName} WHERE id " . $tmp ;  
                return $this->mysqli->query($sql);      
              
            }  
      
              
            function get($id) {  
                $sql = "SELECT * FROM {$this->tabName} WHERE id ={$id}";  
                  
                $result=$this->mysqli->query($sql);  
      
                if($result && $result->num_rows ==1){  
                    return $result->fetch_assoc();  
                }else{  
                    return false;  
                }  
          
            }  
            function getMessList(){  
                $message="";  
                if(!empty($this->messList)){  
                    foreach($this->messList as $value){  
                        $message.=$value."<br>";  
                    }  
                }  
                return $message;      
            }  
        }  
    ?>  

標(biāo)簽: Mysql ssl

版權(quán)申明:本站文章部分自網(wǎng)絡(luò),如有侵權(quán),請聯(lián)系:west999com@outlook.com
特別注意:本站所有轉(zhuǎn)載文章言論不代表本站觀點!
本站所提供的圖片等素材,版權(quán)歸原作者所有,如需使用,請與原作者聯(lián)系。

上一篇:C#實現(xiàn)對郵件的發(fā)送

下一篇: php分頁類