コード例 #1
0
 public function actionIndex()
 {
     $needing_id = $_GET['id'];
     //需求不复杂使用ar
     //需求复杂可用dao(cdbcommand)
     //查询条件多用cdbcreteria类
     $needing = new Needing();
     $info = $needing->find('id=:id', array(':id' => $needing_id));
     //收藏
     $collection = Collection::model()->count('user_id=:user_id and needing_id=:cat_id', array(':user_id' => Yii::app()->user->id, ':cat_id' => $needing_id));
     //验证是否已参与需求
     $needing_gotAll = NeedingPre::model()->findAll('needing_id=:needing_id', array(':needing_id' => $needing_id));
     $needing_gotCheck = NeedingPre::model()->count('needing_id=:needing_id and username=:username', array(':needing_id' => $needing_id, ':username' => Yii::app()->user->name));
     //需求是否已托管
     $needing_tuoguan = NeedingGet::model()->find('needing_id=:needing_id', array(':needing_id' => $needing_id));
     $this->render('index', array('needing' => $info, 'collect_num' => $collection, 'needing_got' => $needing_gotCheck, 'needing_gotAll' => $needing_gotAll, 'needing_tuoguan' => $needing_tuoguan, 'needing_reply' => ''));
 }