发几个常用的sql语句方法-models 模型使用
                            models 目录创建一个 sql.php
{{{
<?php
if (!defined('IN_ANWSION'))
{
	die;
}
class sql_class extends AWS_MODEL
{
    public function add_sql($table,$array){
     //添加数据 
            return $this->insert($bm,$array); 
    } 
   	public function all_sql($table,$where = null,$order = null,$limit = null, $offset = 0){
	    //返回一个表的数据
         $users_list = $this->fetch_all($table,$where,$order,$limit,$offset) ;  
		return array_slice($users_list, 0, null);
     
	}
	public function get_sql_count($table,$where = null){ 
//返回查询影响行数 
    	if($table==null){
	        return 0 ;
	    }
	     return $this->count($table,$where); 
	}
	
	public function row_sql($table,$where){
//返回一行 (第一次出现的数据)
	      return $this->fetch_row($table,$where);
	}
	
	public function update_sql($table,$array,$where){
//修改数据
	     return $this->update($table,$array,$where);
	}
	
	public function del_sql($table,$where){
//删除数据 
	    return $this->delete($table, $where);
	}
	
}
?>
}}}
app 文件里面就可以直接使用 
{{{
$数据 = $this->model('sql')->方法名(相对参数);
}}}
像数组的可以这样子
{{{
$array = arrat(
         'name' => 'admin'
);
$this->model('sql')->add_sql('user',$array);
}}}
对于返回结果自行做些判断吧,这比较通用的,还有些我没用到就没写出来了,还有取最大值最小值。
可以看源码配置方法 自己做些模型方便自己,
 系统文件 `` system/aws_model.inc.php`` sql一些配置文件。!希望对跟我一样小白的有些帮助!
                        
                    
 
                                         
                 
                 
                 
                
2014-12-03 13:00
2014-12-02 09:46
2014-12-02 09:35