//查找满足指定条件的结果中的第一行 find the first row satisfying the specified condition $post=Post::model()->find($condition,$params); //查找具有指定主键值的那一行 find the row with the specified primary key $post=Post::model()->findByPk($postID,$condition,$params); //查找具有指定属性值的行 find the row with the specified attribute values $post=Post::model()->findByAttributes($attributes,$condition,$params);//未找到返回null //通过指定的SQL 语句查找结果中的第一行 find the first row using the specified SQL statement $post=Post::model()->findBySql($sql,$params);
// find the row with postID=10
$post=Post::model()->find('postID=:postID', array(':postID'=>10));
$criteria=new CDbCriteria;
$criteria->select='title'; // only select the 'title' column
$criteria->condition='postID=:postID';
$criteria->params=array(':postID'=>10);
$post=Post::model()->find($criteria); // $params is not needed
$post=Post::model()->find(array(
'select'=>'title',
'condition'=>'postID=:postID',
'params'=>array(':postID'=>10),
));
self::$_items[$type]=array();
$models=self::model()->findAll(array(
'condition'=>'type=:type',
'params'=>array(':type'=>$type),
'order'=>'position',
));
$criteria=new CDbCriteria;
$criteria->select='username'; // only select the 'title' column
$criteria->condition='username=:username';
$criteria->params=array(':username=>'admin');
$post=Post::model()->find($criteria); // $params is not needed
$admin=new Admin;
$admin->username=$username;
$admin->password=$password;
if($admin->save()>0){
echo "添加成功";
}else{
echo "添加失败";
}
$count = Admin::model()->updateAll(array('username'=>'11111','password'=>'11111'),'password=:pass',array(':pass'=>'1111a1'));
if($count>0){
echo "修改成功";
}else{
echo "修改失败";
}
$count = Admin::model()->updateByPk(1,array('username'=>'admin','password'=>'admin'));
$count = Admin::model()->updateByPk(array(1,2),array('username'=>'admin','password'=>'admin'),'username=:name',array(':name'=>'admin'));
if($count>0){
echo "修改成功";
}else{
echo "修改失败";
}
$count =Admin::model()->updateCounters(array('status'=>1),'username=:name',array(':name'=>'admin'));
if($count>0){
echo "修改成功";
}else{
echo "修改失败";
}
$count = Admin::model()->deleteAll('username=:name and password=:pass',array(':name'=>'admin',':pass'=>'admin'));
$id=1,2,3
deleteAll('id in(".$id.")');删除id为这些的数据
if($count>0){
echo "删除成功";
}else{
echo "删除失败";
}
$count = Admin::model()->deleteByPk(1);
$count = Admin::model()->deleteByPk(array(1,2),'username=:name',array(':name'=>'admin'));
if($count>0){
echo "删除成功";
}else{
echo "删除失败";
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有