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


PHP Author::model方法代码示例

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


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

示例1: loadModel

 public function loadModel($id)
 {
     if (($model = Author::model()->findByPk($id)) === null) {
         throw new CHttpException(404, 'Страница не найдена');
     }
     return $model;
 }
开发者ID:kuzmina-mariya,项目名称:gallery,代码行数:7,代码来源:AuthorBackendController.php

示例2: actionView

    /**
     * Displays a particular model.
     * @param integer $id the ID of the model to be displayed
     */
    public function actionView($id, $aBookId = null, $dBookId = null)
    {
        $authorsNames = [];
        $authors = Author::model()->findAllBySql('
		SELECT a.*
		FROM db_author AS a
		INNER JOIN db_authors_books AS ab
		ON ab.author_id = a.id
		WHERE ab.book_id = ' . $id);
        foreach ($authors as $author) {
            $authorsNames[] = $author['name'];
        }
        if (!Yii::app()->user->isGuest) {
            if ($aBookId) {
                $this->addFavorite($aBookId);
                $this->redirect($id, array('model' => $this->loadModel($id), 'isFavorite' => $this->isFavorite($id), 'author' => $authorsNames));
            } elseif ($dBookId) {
                $this->deleteFavorite($dBookId);
                $this->redirect($id, array('model' => $this->loadModel($id), 'isFavorite' => $this->isFavorite($id), 'author' => $authorsNames));
            } else {
                $this->render('view', array('model' => $this->loadModel($id), 'isFavorite' => $this->isFavorite($id), 'author' => $authorsNames));
            }
        } else {
            $this->render('view', array('model' => $this->loadModel($id), 'author' => $authorsNames));
        }
    }
开发者ID:evgeny-yakovets,项目名称:book_site,代码行数:30,代码来源:BookController.php

示例3: run

 public function run()
 {
     $config = new CConfiguration(Yii::app()->basePath . '/config/pager.php');
     $form = new SearchForm();
     // If referrer is not our action delete search parameters from session.
     if (strpos(Yii::app()->request->urlReferrer, '/site/search') === false) {
         Yii::app()->session->remove('siteSearch');
     } else {
         if (!empty(Yii::app()->session['SearchForm'])) {
             $siteSearch = Yii::app()->session['SearchForm'];
             $form->text = $siteSearch['text'];
             $form->authorId = $siteSearch['authorId'];
         }
     }
     if (!empty($_POST['SearchForm']) && is_array($_POST['SearchForm'])) {
         $form->attributes = $_POST['SearchForm'];
         Yii::app()->session['SearchForm'] = array('text' => $form->text, 'authorId' => $form->authorId);
     }
     $criteria = new CDbCriteria();
     $criteria->order = 'approvedTime DESC';
     $criteria->condition = 'approvedTime AND (textRu LIKE :text OR textEn LIKE :text) ' . ($form->authorId ? 'AND (authorId LIKE :authorId)' : '');
     $criteria->params = array(':text' => "%{$form->text}%") + ($form->authorId ? array(':authorId' => $form->authorId) : array());
     $pages = new CPagination(Quote::model()->count($criteria));
     $config->applyTo($pages);
     $pages->applyLimit($criteria);
     $quotes = Quote::model()->with('tags')->findAll($criteria);
     $criteria = new CDbCriteria();
     $criteria->order = 'name';
     $authors = Author::model()->findAll($criteria);
     $this->controller->render('search', array('quotes' => $quotes, 'pages' => $pages, 'form' => $form, 'authors' => $authors));
 }
开发者ID:vchimishuk,项目名称:itquotes,代码行数:31,代码来源:SearchAction.php

示例4: actionPublisher

 public function actionPublisher()
 {
     if ($_POST) {
         //айди издателя
         $idPublisher = CHtml::encode($_POST['search-publishers']);
         $criteria = new CDbCriteria();
         // критерий поиска авторов
         $criteria->compare('publishing_id', $idPublisher);
         // собираем всех авторов
         $modelAuthors = Author::model()->findAll($criteria);
         // все айди авторов
         $arr = array();
         foreach ($modelAuthors as $item) {
             $arr[] = $item->id;
         }
         if ($arr) {
             $criteria = new CDbCriteria();
             $criteria->compare('author_id', $arr);
             $pages = new CPagination(Book::model()->count($criteria));
             $pages->pageSize = Options::getOption('PostOnPage');
             $pages->applyLimit($criteria);
             $model = Book::model()->findAll($criteria);
             $books = array();
             foreach ($model as $item) {
                 $books[] = Front::getBookAll($item->id);
             }
             $this->render('index', ['model' => $books, 'pages' => $pages]);
         } else {
             $this->render('index');
         }
     }
 }
开发者ID:alex-bro,项目名称:yiitest,代码行数:32,代码来源:DefaultController.php

示例5: run

 public function run()
 {
     $session = Yii::app()->session;
     $config = new CConfiguration(Yii::app()->basePath . '/config/pager.php');
     $cookies = Yii::app()->request->cookies;
     // If referrer is not our controller delete search parameters from session.
     if (strpos(Yii::app()->request->urlReferrer, '/quote/list') === false) {
         unset($session['search']);
     }
     if (!empty($_POST['search']) && is_array($_POST['search'])) {
         $search = $_POST['search'];
         $session['search'] = $search;
     } else {
         if (!empty($session['search'])) {
             $search = $session['search'];
         } else {
             $search = array('text' => '', 'authorId' => 0, 'approved' => 'all');
         }
     }
     $criteria = new CDbCriteria();
     $criteria->condition = '(textRu LIKE :text OR textEn LIKE :text) ' . ($search['authorId'] ? 'AND authorId = :authorId ' : '') . ($search['approved'] == 'approved' ? 'AND approvedTime ' : '') . ($search['approved'] == 'unApproved' ? 'AND (approvedTime IS NULL OR approvedTime = 0) ' : '');
     $criteria->params = array(':text' => "%{$search['text']}%") + ($search['authorId'] ? array(':authorId' => $search['authorId']) : array());
     $criteria->order = 'Quote.id DESC';
     $pages = new CPagination(Quote::model()->count($criteria));
     $config->applyTo($pages);
     $pages->applyLimit($criteria);
     $quotes = Quote::model()->with('tags', 'author')->findAll($criteria);
     $showSearchForm = !empty($cookies['showSearchForm']) && $cookies['showSearchForm']->value ? true : false;
     $criteria = new CDbCriteria();
     $criteria->order = 'name';
     $authors = Author::model()->findAll($criteria);
     $this->controller->render('list', array('quotes' => $quotes, 'pages' => $pages, 'authors' => $authors, 'search' => $search, 'showSearchForm' => $showSearchForm));
 }
开发者ID:vchimishuk,项目名称:itquotes,代码行数:33,代码来源:ListAction.php

示例6: loadModel

 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Author::model()->findByAttributes(array('auth_id' => $id));
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
开发者ID:akilraj1255,项目名称:rajeshwari,代码行数:13,代码来源:AuthorsController.php

示例7: run

 public function run()
 {
     $module = Yii::app()->getModule('catalog');
     $counter1 = $module->counter1;
     $counter2 = Author::model()->published()->count();
     $counter3 = $module->counter3;
     $counter4 = $module->counter4;
     $this->render($this->view, array('counter1' => $counter1, 'counter2' => $counter2, 'counter3' => $counter3, 'counter4' => $counter4));
 }
开发者ID:kuzmina-mariya,项目名称:gallery,代码行数:9,代码来源:CountersWidget.php

示例8: run

 public function run()
 {
     $id = !empty($_GET['id']) ? $_GET['id'] : 0;
     $author = Author::model()->findByPk($id);
     if ($author === null) {
         throw new CHttpException(404, 'Author not found');
     }
     $author->delete();
     Yii::app()->user->setFlash('generalMessage', 'Author was deleted successfully.');
     $this->controller->redirect(array('list'));
 }
开发者ID:vchimishuk,项目名称:itquotes,代码行数:11,代码来源:DeleteAction.php

示例9: actionIndex

 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndex()
 {
     $model = array();
     $model['publishers'] = count(Publishing::model()->findAll());
     $model['authors'] = count(Author::model()->findAll());
     $model['books'] = count(Book::model()->findAll());
     $model['pictures'] = count(Picture::model()->findAll());
     // renders the view file 'protected/views/site/index.php'
     // using the default layout 'protected/views/layouts/main.php'
     $this->render('index', ['model' => $model]);
 }
开发者ID:alex-bro,项目名称:yiitest,代码行数:15,代码来源:SiteController.php

示例10: getStatistics

 private function getStatistics()
 {
     $staistics = array();
     if ($this->controller->id == 'quote') {
         // Quotes total count.
         $staistics['totalCount'] = Quote::model()->count();
         // Get number of unapproved quotes.
         $criteria = new CDbCriteria();
         $criteria->condition = 'NOT approvedTime';
         $staistics['unapprovedCount'] = Quote::model()->count($criteria);
     } elseif ($this->controller->id == 'tag') {
         $staistics['totalCount'] = Tag::model()->count();
         $tags = Tag::model()->with('quotesCount')->findAll();
         // Delete tags with empty quotesCount (With PHP > 5.3 e can use closure here).
         // TODO: Rewrite this code for PHP 5.3 when it will be avaliable.
         function tagsFilter($tag)
         {
             return (bool) $tag->quotesCount;
         }
         $tags = array_filter($tags, 'tagsFilter');
         // Sort tags by their weights (quotesCount).
         function tagsSort($a, $b)
         {
             if ($a->quotesCount == $b->quotesCount) {
                 return 0;
             }
             return $a->quotesCount > $b->quotesCount ? -1 : 1;
         }
         usort($tags, 'tagsSort');
         $staistics['popularTags'] = array_slice($tags, 0, 10);
     } elseif ($this->controller->id == 'author') {
         $staistics['totalCount'] = Author::model()->count();
         $authors = Author::model()->with('quotesCount')->findAll();
         // Delete authors with empty quotesCount (With PHP > 5.3 e can use closure here).
         // TODO: Rewrite this code for PHP 5.3 when it will be avaliable.
         function authorsFilter($author)
         {
             return (bool) $author->quotesCount;
         }
         $authors = array_filter($authors, 'authorsFilter');
         // Sort tags by their weights (quotesCount).
         function authorsSort($a, $b)
         {
             if ($a->quotesCount == $b->quotesCount) {
                 return 0;
             }
             return $a->quotesCount > $b->quotesCount ? -1 : 1;
         }
         usort($authors, 'authorsSort');
         $staistics['popularAuthors'] = array_slice($authors, 0, 10);
     }
     return $staistics;
 }
开发者ID:vchimishuk,项目名称:itquotes,代码行数:53,代码来源:AdminToolbox.php

示例11: run

 public function run()
 {
     $config = new CConfiguration(Yii::app()->basePath . '/config/pager.php');
     $author = Author::model()->findByPk($_GET['authorId']);
     if ($author === null) {
         throw new CHttpException(404, 'Author not found');
     }
     $criteria = new CDbCriteria();
     $criteria->condition = 'authorId = :authorId';
     $criteria->params = array(':authorId' => $author->id);
     $pages = new CPagination(Quote::model()->count($criteria));
     $config->applyTo($pages);
     $pages->applyLimit($criteria);
     $quotes = Quote::model()->findAll($criteria);
     $this->controller->render('author', array('author' => $author, 'quotes' => $quotes, 'pages' => $pages));
 }
开发者ID:vchimishuk,项目名称:itquotes,代码行数:16,代码来源:AuthorAction.php

示例12: run

 public function run()
 {
     $id = !empty($_GET['id']) ? $_GET['id'] : 0;
     $author = Author::model()->findByPk($id);
     if ($author === null) {
         throw new CHttpException(404, 'Author not found');
     }
     if (!empty($_POST['Author']) && is_array($_POST['Author'])) {
         // Form was submitted.
         $author->attributes = $_POST['Author'];
         if ($author->save()) {
             Yii::app()->user->setFlash('generalMessage', 'Author was saved successfully.');
             $this->controller->redirect(array('list'));
         }
     }
     $this->controller->render('edit', array('author' => $author));
 }
开发者ID:vchimishuk,项目名称:itquotes,代码行数:17,代码来源:EditAction.php

示例13: getBookAll

 public static function getBookAll($id)
 {
     $book = array();
     $modelBook = Book::model()->findByPk($id);
     $book['name'] = $modelBook->name;
     $book['date'] = $modelBook->date;
     $modelAuthor = Author::model()->findByPk($modelBook->author_id);
     $book['author'] = $modelAuthor->name;
     $modelPublisher = Publishing::model()->findByPk($modelAuthor->publishing_id);
     $book['publisher'] = $modelPublisher->name;
     $modelCategory = Category::model()->findByPk($modelBook->category_id);
     $book['category'] = $modelCategory->name;
     $criteria = new CDbCriteria();
     $criteria->compare('book_id', $modelBook->id);
     $bookPicture = Picture::model()->findAll($criteria);
     $book['pictures'] = array();
     foreach ($bookPicture as $pic) {
         $book['pictures'][] = $pic->image;
     }
     return $book;
 }
开发者ID:alex-bro,项目名称:yiitest,代码行数:21,代码来源:Front.php

示例14: foreach

</td>
<td align="center"><?php 
    echo Yii::t('library', 'Due Date');
    ?>
</td>
<td align="center"><?php 
    echo Yii::t('library', 'Is returned');
    ?>
</td>
</tr>

<?php 
    if ($book != NULL) {
        foreach ($book as $book_1) {
            $bookdetails = Book::model()->findByAttributes(array('id' => $book_1->book_id));
            $author = Author::model()->findByAttributes(array('auth_id' => $bookdetails->author));
            $publication = Publication::model()->findByAttributes(array('publication_id' => $bookdetails->publisher));
            ?>
<tr>

<td align="center"><?php 
            echo $student->last_name . ' ' . $student->first_name;
            ?>
</td>
<td align="center"><?php 
            echo $bookdetails->isbn;
            ?>
</td>
<td align="center"><?php 
            echo $bookdetails->title;
            ?>
开发者ID:akilraj1255,项目名称:rajeshwari,代码行数:31,代码来源:manage.php

示例15: actionInitAuthor

 public function actionInitAuthor()
 {
     $model = Author::model()->find('id=:author_id', array(':author_id' => (int) $_GET['id']));
     if ($model !== null) {
         echo CJSON::encode(array('id' => $model->id, 'text' => $model->author_name));
     }
 }
开发者ID:noonnightcoder,项目名称:bakou-pos-apsara,代码行数:7,代码来源:AuthorController.php


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