本文整理汇总了PHP中Shop::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Shop::model方法的具体用法?PHP Shop::model怎么用?PHP Shop::model使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shop
的用法示例。
在下文中一共展示了Shop::model方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadModel
public function loadModel($id)
{
$model = Shop::model()->findByPk($id);
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
return $model;
}
示例2: relations
/**
* Relations.
*
* @return array Relations.
*/
public function relations()
{
return array('shop' => array(self::BELONGS_TO, Shop::model()->tableName(), 'shop_id'));
}
示例3: actionShop
public function actionShop()
{
$model = new Comment();
// $criteria = new CDbCriteria();
// $criteria->with = array ('user');
$id = Yii::app()->request->getParam('id');
// $commentlist = Comment::model()->findAllByAttributes(array('sid'=>$id),$criteria);
$commentlist = Comment::model()->with('user')->findAllByAttributes(array('sid' => $id));
$shop = Shop::model()->findByPk($id);
if (isset($_POST['Comment'])) {
$role = Yii::app()->user->getId();
if (!empty($role)) {
if (Yii::app()->user->roles != '0' && Yii::app()->user->roles != '1') {
$this->redirect(Yii::app()->createURL('site/login'));
}
} else {
$this->redirect(Yii::app()->createURL('site/login'));
}
date_default_timezone_set('Asia/Shanghai');
$model->postdate = date("Y-m-d H:i:s");
$model->attributes = $_POST['Comment'];
$model->sid = $id;
$model->uid = Yii::app()->user->uid;
if ($model->save()) {
$this->redirect(Yii::app()->createURL('site/shop/id/' . $id));
} else {
print_r($model->getErrors());
exit;
}
}
$this->render('shop', array('model' => $model, 'commentlist' => $commentlist, 'shop' => $shop));
// $this->render('test');
}