һݿʼ

//ݿ
$config['DB_TYPE']='mysql';//ݿ
$config['DB_HOST']='localhost';//ݿ
$config['DB_USER']='root';//ݿû
$config['DB_PWD']='123456';//ݿ
$config['DB_PORT']='3306';//ݿ˿ڣmysqlĬ3306һ㲻Ҫ޸
$config['DB_NAME']='cp';//ݿ
$config['DB_CHARSET']='utf8';//ݿ
$config['DB_PREFIX']='cp_';//ݿǰ׺
$config['DB_PCONNECT']=false;//trueʾʹӣfalseʾӣһ㲻ʹ

$config['DB_CACHE_ON']=false;//Ƿݿ⻺棬truefalse
$config['DB_CACHE_PATH']='./data/db_cache/';//ݿѯݻĿ¼ַļ
$config['DB_CACHE_TIME']=0;//ʱ,0棬-1û
$config['DB_CACHE_CHECK']=false;//ǷԻУ
//ݿý
require(CP_PATH.'core/cpModel.class.php');//ݿģ
$model=new cpModel($config);//ʵģ


ݲѯ
1ѯһݣ
	$info=$model->table('')->where($condition)->find();
	ɹһά飬򷵻false
	
	ֶ
	$info=$model->table('')->field('id,title')->where($condition)->find();
	
	
	$info=$model->table('')->field('id,title')->where($condition)->order('id desc')->find();	
	ע:order('id desc')order('id asc')
	
	
	$info=$model->table('')->cache(10)->where($condition)->find();
	cache($time) $time>0,ݻʱ䣬$time=0,$time=-1û
	
2ѯ
	$list=$model->table('')->where($condition)->select();
	ɹضά飬򷵻false
	ֶ
	$list=$model->table('')->field('id,title')->where($condition)->select();
	
	
	$list=$model->table('')->field('id,title')->where($condition)->order('id desc')->select();
	
	
	$list=$model->table('')->field('id,title')->where($condition)->order('id desc')->limit(10)->select();
	
	
	$list=$model->table('')->cache($time)->field('id,title')->where($condition)->order('id desc')->limit(10)->select();
	cache($time) $time>0,ݻʱ䣬$time=0,$time=-1û
	
3ѯ
	$count=$model->table('')->where($condition)->count();
	ɹһ򷵻false
	
	$count=$model->table('')->cache($time)->where($condition)->count();

ע:field(),limit(),order(),cache(),table(),where()ûȺ˳֮
$conditionΪַ飬飬±ʾݿֶ Ԫand
һģдԭsqlѯ


	
	$model->table('')->data($data)->insert();

	$dataΪ 
		$data['name']='admin';
		$data['email']='404352772@q.com';
	ɹزݵid򷵻false


ġ
	
	$model->table('')->data($data)->where($condition)->update();
	$dataΪ 
		$data['name']='admin';
		$data['email']='404352772@q.com';
	$conditionΪѯ,Ϊַ,$condition['id']=1;
	³ɹӰ򷵻false


塢ɾ
	$model->table('')->where($condition)->delete();
	$conditionΪѯ,Ϊַ,$condition['id']=1;
	ɾɹӰ򷵻false

ԭsqlִ
	$model->query($sql);
	$sqlΪѯ򷵻ضά飬ҿû$model->cache->query($sql);
	sqlǲѯ䣬Чصݸmysql_query($sql)һ
