当前位置: 首页>>代码示例>>PHP>>正文


PHP Author::findOne方法代码示例

本文整理汇总了PHP中app\models\Author::findOne方法的典型用法代码示例。如果您正苦于以下问题:PHP Author::findOne方法的具体用法?PHP Author::findOne怎么用?PHP Author::findOne使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\models\Author的用法示例。


在下文中一共展示了Author::findOne方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionDelete

 /**
  * Удаление автора.
  *
  * @param int $id
  * @return \yii\web\Response
  */
 public function actionDelete($id)
 {
     /** @var Author $modelAuthor */
     $modelAuthor = Author::findOne($id);
     if ($modelAuthor->delete()) {
         return $this->redirect(['back-author/index']);
     }
     return $this->refresh();
 }
开发者ID:Rey8d01,项目名称:book-catalog,代码行数:15,代码来源:BackAuthorController.php

示例2: _saveBook

 /**
  * Сохраняет модель и связанные данные
  *
  * @param Book $modelBook
  * @return \yii\web\Response
  */
 private function _saveBook(Book $modelBook)
 {
     $authorIds = Yii::$app->request->post('authors');
     $tagIds = Yii::$app->request->post('tags');
     if ($modelBook->load(Yii::$app->request->post()) && $modelBook->save()) {
         array_map(function ($model) use($modelBook) {
             $modelBook->unlink('authors', $model, true);
         }, $modelBook->authors);
         foreach ($authorIds ?: [] as $authorId) {
             /** @var Author $modelAuthor */
             $modelAuthor = Author::findOne($authorId);
             $modelBook->link('authors', $modelAuthor);
         }
         array_map(function ($model) use($modelBook) {
             $modelBook->unlink('tags', $model, true);
         }, $modelBook->tags);
         foreach ($tagIds ?: [] as $tagId) {
             /** @var Tag $modelTag */
             $modelTag = Tag::findOne($tagId);
             $modelBook->link('tags', $modelTag);
         }
         return $this->redirect(['back-book/view', 'id' => $modelBook->id]);
     }
 }
开发者ID:Rey8d01,项目名称:book-catalog,代码行数:30,代码来源:BackBookController.php

示例3: runPKSearch

 public function runPKSearch($i)
 {
     $author = $this->authors[array_rand($this->authors)];
     $author = Author::findOne($author->id);
     //        $this->em->clear();
 }
开发者ID:motin,项目名称:forked-php-orm-benchmark,代码行数:6,代码来源:Yii2MTestSuite.php

示例4: findModel

 /**
  * Finds the Author model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Author the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Author::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
开发者ID:Oleg25,项目名称:RGK-Group,代码行数:15,代码来源:AuthorController.php

示例5: actionView

 /**
  * Displays a single Book model.
  * @param integer $id
  * @return mixed
  */
 public function actionView($id)
 {
     $model = $this->findModel($id);
     return $this->render('view', ['model' => $model, 'author' => (new AuthorEntity())->createEntity(Author::findOne($model->author_id))]);
 }
开发者ID:GotFly,项目名称:books,代码行数:10,代码来源:BookController.php

示例6: actionGetTags

 /**
  * Генератор тэговых страниц
  */
 public function actionGetTags()
 {
     $list = scandir('/home/romanych/www/vrs/pages/');
     $list = array_diff($list, ['.', '..']);
     //var_dump($list); exit;
     $alphabet = fopen("/home/romanych/www/vrs/alphabet.html", "w");
     fwrite($alphabet, self::$header);
     foreach ($list as $letter) {
         fwrite($alphabet, "<div class='letters'><a href='pages/" . $letter . "/tags.html'>" . $letter . "</a></div>");
         $alfa_tags = fopen("/home/romanych/www/vrs/pages/" . $letter . "/tags.html", "w");
         fwrite($alfa_tags, self::$header);
         fwrite($alfa_tags, self::$footer);
         fclose($alfa_tags);
     }
     fwrite($alphabet, self::$footer);
     fclose($alphabet);
     $tags = Tag::find()->orderBy('name')->all();
     //var_dump($tags); exit;
     //$file =  fopen("/home/romanych/www/vrs/tags.html", "w");
     //fwrite($file, self::$header);
     foreach ($tags as $tag) {
         $first_letter = mb_substr($tag->name, 0, 1, 'UTF-8');
         //var_dump($first_letter); exit;
         $big_first_letter = mb_strtoupper($first_letter, 'UTF-8');
         $alfa_tags = fopen("/home/romanych/www/vrs/pages/" . $big_first_letter . "/tags.html", "a");
         fwrite($alfa_tags, "<a href='" . TranslateHelper::translit($tag->name) . ".html'><button type='button' class='btn btn-default btn-lg'>{$tag->name}</button></a>");
         fwrite($alfa_tags, self::$footer);
         fclose($alfa_tags);
         //fwrite($file, "<p><a href='pages/".$big_first_letter."/". TranslateHelper::translit($tag->name) .".html'>$tag->name</a></p>");
         $page = fopen("/home/romanych/www/vrs/pages/" . $big_first_letter . "/" . TranslateHelper::translit($tag->name) . ".html", "w");
         fwrite($page, '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
                         <link rel="stylesheet" type="text/css" href="../../css/bootstrap.min.css">
                         <meta name="viewport" content="width=device-width, initial-scale=1.0">
                         <style>.item_head{font-weight: bold;} body{padding-left: 20px; padding-top: 20px;} </style>');
         $items = explode(",", $tag->items);
         $r = 1;
         foreach ($items as $item) {
             try {
                 $item = Items::findOne(['id' => (int) $item]);
                 $source = Source::findOne(['id' => $item->source_id]);
                 $author = Author::findOne(['id' => $source->author_id]);
                 fwrite($page, "<p class='item_head'>{$r} {$item->title} ({$author->name} - {$source->title})</p>\n                    " . $this->renderPlayer($item->audio_link) . "\n                    " . nl2br("<p>{$item->text}</p>") . "\n\n                    ");
             } catch (\ErrorException $e) {
                 echo $e->getMessage() . PHP_EOL;
                 var_dump(Items::findOne(['id' => (int) $item]));
             }
             $r++;
         }
         fwrite($page, self::$footer);
         fclose($page);
     }
     //fwrite($file, self::$footer);
     //fclose($file);
 }
开发者ID:roman1970,项目名称:lis,代码行数:57,代码来源:ParsersController.php


注:本文中的app\models\Author::findOne方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。