私は yii を使用してアプリケーションに取り組んでいます。アクション let がありacmanageappointments/index
ます。そのルールを次のように定義しました
array('allow', // allow authenticated user to perform 'create' and 'update' actions
'actions'=>array('index','create','update','delete','updatestatus'),
'users'=>array('@'),
そのアクションは次のとおりです。
public function actionIndex()
{
$user_id = Yii::app()->user->getId();
$criteria = new CDbCriteria();
$criteria->condition = 'user_id='.$user_id;
$count=AcAppointments::model()->count($criteria);
$pages=new CPagination($count);
//results per page
$pages->pageSize=10;
$pages->applyLimit($criteria);
$AllAppointments = AcAppointments::model()->findAll($criteria);
// Applying Global Date Time Format
$condition = array('user_id' => $user_id);
$DTFormat = CalendarSettings::model()->findByAttributes($condition);
$this->render('index',array(
'AllAppointments' => $AllAppointments,
'pages' => $pages,
'DTFormat' => $DTFormat,
));
}
このアクションは、認証された人物のみがアクセスできます。ログインすると、この機能は正しく機能しています。しかし、ログアウトしてこのアクションを実行すると、CDbException
. この例外を処理するにはどうすればよいですか。また、ユーザーがログアウトしたときにこの URL にアクセスしようとすると、ログイン ページにリダイレクトする必要があります。これどうやってするの ?
更新:ここに私のアクセスルールがあります:
public function accessRules()
{
return array(
array('allow', // allow authenticated user to perform 'create' and 'update' actions
'actions'=>array('index','create','update','delete','updatestatus'),
'users'=>array('@'),
),
array('deny', // deny all users
'users'=>array('*'),
),
);
}
ここにエラーがあります:
CDbCommand failed to execute the SQL statement: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1