Yii学习

时间:2021-07-30 06:38:37

今天保存出错,但是什么也没提示,所以就查了下,怎么输出错误

$model->save();

$model->getErrors();

获取,刚插入数据的id

$reply->save();

$reply->attributes['id'];

"keyword != '' and keyword is not null and keyword != '*'"

YourModel::find()
->andWhere(['!=','keyword',''])
->andWhere(['is not','keyword',null])
->andWhere(['!=','keyword','*'])
->All();

name!=aa and  order_id=1 and status=1

YourModel::find()->where(['and',['!=','name','aa'],['order_id'=>$order_id,'status'=>1]])

Yii生成URL

echo Url::toRoute(['page', 'id' => 'contact']);

echo Url::toRoute('post/index');

echo \Yii::$app->urlManager->createUrl(['site/page', 'id' => 'about']);