本文整理汇总了PHP中app\models\Book::getIntDate方法的典型用法代码示例。如果您正苦于以下问题:PHP Book::getIntDate方法的具体用法?PHP Book::getIntDate怎么用?PHP Book::getIntDate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Book
的用法示例。
在下文中一共展示了Book::getIntDate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: search
public function search($params)
{
$query = Book::find();
$dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['name' => SORT_ASC]]]);
// join with relation `whose` that is a relation to the table `user`
// and set the table alias to be `whose`
$query->joinWith(['author' => function ($query) {
$query->from(['author' => 'tz_author']);
}]);
// enable sorting for the related column
$dataProvider->sort->attributes['author.last_name'] = ['asc' => ['author.last_name' => SORT_ASC], 'desc' => ['author.last_name' => SORT_DESC]];
// load the search form data and validate
if (!($this->load($params) && $this->validate())) {
return $dataProvider;
}
// adjust the query by adding the filters
$query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'author.last_name', $this->getAttribute('author.last_name')])->andFilterWhere(['between', 'date', $this->date ? Book::getIntDate($this->date) : $this->date, $this->after_date ? Book::getIntDate($this->after_date) : $this->after_date]);
return $dataProvider;
}
示例2: actionUpdate
/**
* Updates an existing Book model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
*/
public function actionUpdate($id)
{
$model = $this->findModel($id);
$oldImage = $model->preview;
if ($model->load(Yii::$app->request->post())) {
$image = UploadedFile::getInstance($model, 'preview');
if (!empty($image)) {
unlink(Yii::$app->params['uploadPath'] . $oldImage);
$temp_var = explode(".", $image->name);
$ext = end($temp_var);
$model->preview = Yii::$app->security->generateRandomString() . ".{$ext}";
$path = Yii::$app->params['uploadPath'] . $model->preview;
$image->saveAs($path);
}
$model->date = Book::getIntDate($model->date);
$model->save();
$session = Yii::$app->session;
if (!$session->isActive) {
$session->open();
}
$session->set('needSearchParam', true);
return $this->redirect(['index']);
} else {
return $this->render('update', ['model' => $model, 'author' => Author::find()->all()]);
}
}