首页 > 其他 > 详细

CI框架学习之六 ( 常用函数封装 )

时间:2015-04-09 13:43:58      阅读:204      评论:0      收藏:0      [点我收藏+]
        /**
	 *  封装查询函数
	 */
	public function get_what($table='',$where=array(),$fields = ' * '){
		if( '' == $table ){
			return false;
		}
		//查询并返回相关结果
		$query = $this->db->select($fields)->where($where)->get($table);
		$res = $query->result_array();
		return $res;
	}

	/**
	 *  封装更新函数
	 */
	public function update_what($table='', $where=array(), $data = array()){
		if('' == $table || true === empty($where) || true === empty($data)){
			return false;
		}
		//更新相应的字段
		$query = $this->db->update($table,$data,$where);
		return $query;
	}


	/**
	 *  封装插入函数
	 */
	public function insert_what($table = '', $data = array()){
		if('' == $table || true === empty($data)){
			return false;
		}
		//插入 相关记录
		$query = $this->db->insert($table, $data);
		return $query;
	}


	/**
	 *  删除记录封装函数
	 */
	public function delete_what($table = '', $where=array()){
		if(true === empty($where) || '' == $table){
			return false;
		}
		//删除相关表记录
		$query = $this->db->delete($table,$where);
		return $query;
	}

    /**
     * debug 相关函数
     */
	public function debug_what($org_error = ''){
		$con = $this->router->fetch_class();
	    $func = $this->router->fetch_method();

	    if($org_error){
			$error .= date("Y-m-d H:i:s",time())."\r\n";
			$error .= __FILE__."\r\n";
	        $error .= $con." 控制器下的:\r\n";
			$error .= $func." 方法调试信息如下:\r\n";
			$error .= $org_error;
			file_put_contents("./error_log.txt",$error."\r\n",FILE_APPEND);
		}
	}


CI框架学习之六 ( 常用函数封装 )

原文:http://blog.csdn.net/wujiangwei567/article/details/44958903

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!