當前位置: 首頁>>代碼示例>>PHP>>正文


PHP models\Authors類代碼示例

本文整理匯總了PHP中app\models\Authors的典型用法代碼示例。如果您正苦於以下問題:PHP Authors類的具體用法?PHP Authors怎麽用?PHP Authors使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Authors類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getAuthorsForDropDownList

 /**
  * @return array(['id' => 'fullname])
  */
 public static function getAuthorsForDropDownList()
 {
     $authorsModels = Authors::find()->all();
     $authors = ArrayHelper::toArray($authorsModels, ['app\\models\\Authors' => ['id', 'fullname' => function ($model) {
         return "{$model->firstname} {$model->lastname}";
     }]]);
     return ArrayHelper::map($authors, 'id', 'fullname');
 }
開發者ID:Dr1N,項目名稱:BooksOrganizer,代碼行數:11,代碼來源:Authors.php

示例2: getAuthorsName

 public static function getAuthorsName($id = null)
 {
     $results = ['' => 'Не указан'];
     foreach (Authors::find()->all() as $data) {
         $results[$data->id] = $data->lastname . ' ' . $data->firstname;
     }
     return !empty($id) ? $results[$id] : $results;
 }
開發者ID:Diakonrus,項目名稱:test_zadanie,代碼行數:8,代碼來源:Authors.php

示例3: getAuthors

 public static function getAuthors()
 {
     $result = ['' => ''];
     $x = Authors::find()->all();
     foreach ($x as $author) {
         $result[$author->id] = "{$author->firstname} {$author->lastname}";
     }
     return $result;
 }
開發者ID:Pontorez,項目名稱:kgr,代碼行數:9,代碼來源:Authors.php

示例4: map

 public static function map()
 {
     $authors = Authors::find()->all();
     $map = array();
     array_walk($authors, function ($val) use(&$map) {
         $map[$val->id] = $val->firstname . ' ' . $val->lastname;
     });
     return $map;
 }
開發者ID:gluck1986,項目名稱:yii2test,代碼行數:9,代碼來源:Authors.php

示例5: getList

 public static function getList()
 {
     $list = [];
     $authors = Authors::find()->all();
     foreach ($authors as $author) {
         $list[$author->id] = $author->firstname . ' ' . $author->lastname;
     }
     return $list;
 }
開發者ID:verve000,項目名稱:verve000,代碼行數:9,代碼來源:Authors.php

示例6: actionUpdate

 /**
  * Updates an existing Books 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);
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('update', ['model' => $model, 'authors' => $this->getAuthorsArray(Authors::find()->all())]);
     }
 }
開發者ID:alaz1987,項目名稱:books,代碼行數:15,代碼來源:BooksController.php

示例7: getAuthors

 public function getAuthors()
 {
     $authors = Authors::find()->orderBy('firstname')->all();
     $lastname = ArrayHelper::map($authors, 'id', 'lastname');
     $firstname = ArrayHelper::map($authors, 'id', 'firstname');
     foreach ($lastname as $key => $value) {
         $fullName[$key] = $firstname[$key] . ' ' . $lastname[$key];
     }
     return $fullName;
 }
開發者ID:vitaloldos,項目名稱:books,代碼行數:10,代碼來源:AuthorsSearch.php

示例8: getAuthorList

 public static function getAuthorList()
 {
     $list = array();
     $authors = Authors::find()->all();
     //Все авторы
     foreach ($authors as $value) {
         $list[$value->id] = $value->firstname . " " . $value->lastname;
     }
     return $list;
 }
開發者ID:74Genesis,項目名稱:BooksCatalog-yii2,代碼行數:10,代碼來源:Books.php

示例9: search

 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Authors::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'firstname', $this->firstname])->andFilterWhere(['like', 'lastname', $this->lastname]);
     return $dataProvider;
 }
開發者ID:kh0rn,項目名稱:test_app_yii2,代碼行數:18,代碼來源:AuthorsSeach.php

示例10: getNameAuthor

 public static function getNameAuthor($id = NULL)
 {
     if ($id == NULL) {
         return NULL;
     }
     $author = Authors::find()->where(['id' => $id])->asArray()->one();
     if (!empty($author)) {
         return $author['firstname'] . ' ' . $author['lastname'];
     } else {
         return NULL;
     }
 }
開發者ID:Wulfagor,項目名稱:Testing-Task,代碼行數:12,代碼來源:Authors.php

示例11: actionUpdate

 /**
  * Updates an existing Books 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);
     $model_b_a_rel = BookAuthorRel::findOne(['b_id' => $id]);
     $authorsArr = Authors::authorArr();
     if ($model->load(Yii::$app->request->post()) && $model_b_a_rel->load(Yii::$app->request->post())) {
         $model->save();
         $model_b_a_rel->saveMultiple(1);
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('update', ['model' => $model, 'model_b_a_rel' => $model_b_a_rel, 'authorsArr' => $authorsArr]);
     }
 }
開發者ID:snedi,項目名稱:book-management,代碼行數:19,代碼來源:BooksController.php

示例12: search

 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Authors::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'date_create' => $this->date_create, 'date_update' => $this->date_update]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
開發者ID:snedi,項目名稱:imot,代碼行數:21,代碼來源:AuthorsSearch.php

示例13: search

 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Authors::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->setSort(['attributes' => ['id', 'fullName' => ['asc' => ['first_name' => SORT_ASC, 'last_name' => SORT_ASC], 'desc' => ['first_name' => SORT_DESC, 'last_name' => SORT_DESC], 'label' => 'Full Name', 'default' => SORT_ASC]]]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'firstname', $this->firstname])->andFilterWhere(['like', 'lastname', $this->lastname])->andWhere('first_name LIKE "%' . $this->fullName . '%" ' . 'OR last_name LIKE "%' . $this->fullName . '%"');
     return $dataProvider;
 }
開發者ID:fedman,項目名稱:books,代碼行數:22,代碼來源:AuthorsSearch.php

示例14: search

 public function search($params)
 {
     $query = Authors::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->setSort(['attributes' => ['id', 'fullName' => ['asc' => ['firstname' => SORT_ASC, 'lastname' => SORT_ASC], 'desc' => ['firstname' => SORT_DESC, 'lastname' => SORT_DESC], 'default' => SORT_ASC], 'firstname', 'lastname']]);
     $this->load($params);
     if (!$this->validate()) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'firstname', $this->firstname]);
     $query->andFilterWhere(['like', 'lastname', $this->lastname]);
     $query->andWhere('firstname LIKE "%' . $this->fullName . '%" ' . 'OR lastname LIKE "%' . $this->fullName . '%"');
     return $dataProvider;
 }
開發者ID:verve000,項目名稱:verve000,代碼行數:15,代碼來源:AuthorsSearch.php

示例15: actionUpdate

 /**
  * Updates an existing Books model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $authors = Authors::getAuthorsForDropDownList();
     $model = $this->findModel($id);
     //Request from form
     if (Yii::$app->request->isPost) {
         $model->load(Yii::$app->request->post());
         $model->cover = UploadedFile::getInstance($model, 'cover');
         if ($model->save()) {
             $absoluteUrl = Yii::$app->session->has('absoluteUrl') ? Yii::$app->session->get('absoluteUrl') : Yii::$app->urlManager->createUrl("books");
             return $this->redirect($absoluteUrl);
         }
     }
     //Render update form
     return $this->render('update', ['model' => $model, 'authors' => $authors]);
 }
開發者ID:Dr1N,項目名稱:BooksOrganizer,代碼行數:22,代碼來源:BooksController.php


注:本文中的app\models\Authors類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。