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


PHP BookQuery类代码示例

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


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

示例1: create

 /**
  * Returns a new BookQuery object.
  *
  * @param     string $modelAlias The alias of a model in the query
  * @param   BookQuery|Criteria $criteria Optional Criteria to build the query from
  *
  * @return BookQuery
  */
 public static function create($modelAlias = null, $criteria = null)
 {
     if ($criteria instanceof BookQuery) {
         return $criteria;
     }
     $query = new BookQuery(null, null, $modelAlias);
     if ($criteria instanceof Criteria) {
         $query->mergeWith($criteria);
     }
     return $query;
 }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:19,代码来源:BaseBookQuery.php

示例2: testFilterById

 /**
  * testFilterById
  *
  * Various test for filterById functions
  * Id's are autoincrement so we have to use a Select to get current ID's
  *
  */
 public function testFilterById()
 {
     // find by single id
     $book = PropelQuery::from('Book b')->where('b.Title like ?', 'Don%')->orderBy('b.ISBN', 'desc')->findOne();
     $c = BookQuery::create()->filterById($book->getId());
     $book2 = $c->findOne();
     $this->assertTrue($book2 instanceof Book);
     $this->assertEquals('Don Juan', $book2->getTitle());
     //find range
     $booksAll = PropelQuery::from('Book b')->orderBy('b.ID', 'asc')->find();
     $booksIn = BookQuery::create()->filterById(array($booksAll[1]->getId(), $booksAll[2]->getId()))->find();
     $this->assertTrue($booksIn[0] == $booksAll[1]);
     $this->assertTrue($booksIn[1] == $booksAll[2]);
     // filter by min value with greater equal
     $booksIn = null;
     $booksIn = BookQuery::create()->filterById(array('min' => $booksAll[2]->getId()))->find();
     $this->assertTrue($booksIn[1] == $booksAll[3]);
     // filter by max value with less equal
     $booksIn = null;
     $booksIn = BookQuery::create()->filterById(array('max' => $booksAll[1]->getId()))->find();
     $this->assertTrue($booksIn[1] == $booksAll[1]);
     // check backwards compatibility:
     // SELECT  FROM `book` WHERE book.id IN (:p1,:p2)
     // must be the same as
     // SELECT  FROM `book` WHERE (book.id>=:p1 AND book.id<=:p2)
     $minMax = BookQuery::create()->filterById(array('min' => $booksAll[1]->getId(), 'max' => $booksAll[2]->getId()))->find();
     $In = BookQuery::create()->filterById(array($booksAll[1]->getId(), $booksAll[2]->getId()))->find();
     $this->assertTrue($minMax[0] === $In[0]);
     $this->assertTrue(count($minMax->getData()) === count($In->getData()));
 }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:37,代码来源:PropelQueryTest.php

示例3: create_rss

function create_rss($search, $limit)
{
    $title = 'uBook';
    if ($search) {
        $title .= ' - Suche nach "' . $search . '"';
    }
    $link = WEBDIR;
    $desc = 'Neue Angebote bei uBook.';
    $lang = 'de-de';
    $copyright = 'uBook';
    $rss = new RssChannel($title, $link, $desc, $lang, $copyright);
    $imageUrl = 'http://ubook.asta-bielefeld.de/ubook_small.gif';
    $rss->addImage($imageUrl, $title, $link);
    $query = BookQuery::searchQuery($search);
    $query .= ' order by created desc';
    if ($limit > 0) {
        $query .= ' limit ' . $limit;
    }
    $mysqlResult = mysql_query($query);
    while ($book = Book::fromMySql($mysqlResult)) {
        $title = $book->get('title');
        $desc = 'Neues Buchangebot:' . "\n" . $book->asText();
        $desc = nl2br(Parser::text2html($desc));
        $id = $link = WEBDIR . 'book.php?id=' . $book->get('id');
        $author = 'ubook@asta-bielefeld.de (uBook-Team)';
        $date = $book->get('created');
        $rss->addItem($id, $title, $desc, $link, $author, $date);
    }
    return $rss;
}
开发者ID:BackupTheBerlios,项目名称:ubook-svn,代码行数:30,代码来源:rss.php

示例4: testFrom

 public function testFrom()
 {
     $q = PropelQuery::from('Book');
     $expected = new BookQuery();
     $this->assertEquals($expected, $q, 'from() returns a Model query instance based on the model name');
     $q = PropelQuery::from('Book b');
     $expected = new BookQuery();
     $expected->setModelAlias('b');
     $this->assertEquals($expected, $q, 'from() sets the model alias if found after the blank');
     $q = PropelQuery::from('myBook');
     $expected = new myBookQuery();
     $this->assertEquals($expected, $q, 'from() can find custom query classes');
     try {
         $q = PropelQuery::from('Foo');
         $this->fail('PropelQuery::from() throws an exception when called on a non-existing query class');
     } catch (PropelException $e) {
         $this->assertTrue(true, 'PropelQuery::from() throws an exception when called on a non-existing query class');
     }
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:19,代码来源:PropelQueryTest.php

示例5: testGetResultsRespectsFormatter

 public function testGetResultsRespectsFormatter()
 {
     $this->createBooks(5);
     $query = BookQuery::create();
     $query->setFormatter(ModelCriteria::FORMAT_ARRAY);
     $pager = new PropelModelPager($query, 4);
     $pager->setPage(1);
     $pager->init();
     $this->assertTrue($pager->getResults() instanceof PropelArrayCollection, 'getResults() returns a PropelArrayCollection if the query uses array hydration');
 }
开发者ID:keneanung,项目名称:gw2spidy,代码行数:10,代码来源:PropelModelPagerTest.php

示例6: testSerializeHydratedObject

 public function testSerializeHydratedObject()
 {
     $book = new Book();
     $book->setTitle('Foo3');
     $book->setISBN('1234');
     $book->save();
     BookPeer::clearInstancePool();
     $book = BookQuery::create()->findOneByTitle('Foo3');
     $sb = serialize($book);
     $this->assertEquals($book, unserialize($sb));
 }
开发者ID:kcornejo,项目名称:estadistica,代码行数:11,代码来源:BaseObjectSerializeTest.php

示例7: findOrCreateOne

 public function findOrCreateOne($book_name)
 {
     # Attempt to find book
     $book = BookQuery::create()->filterByName($book_name)->findOne();
     # Return or create book
     if ($book) {
         return $book;
     } else {
         $book = new Book();
         $book->setName($book_name)->save();
         return $book;
     }
 }
开发者ID:arneau,项目名称:godsworks,代码行数:13,代码来源:BookQuery.php

示例8: testLocales

 public function testLocales()
 {
     $q = \BookQuery::create();
     $q->setLocale('de');
     $q->filterByTitle('Herr der Ringe');
     $b = $q->findOne();
     $this->assertNotNull($b);
     $q = \BookQuery::create();
     $q->setLocale('de');
     $q->filterByTitle('Yubiwa Monogatari', null, 'ja-latn-JP');
     $b = $q->findOne();
     $this->assertNotNull($b);
 }
开发者ID:gossi,项目名称:propel-l10n-behavior,代码行数:13,代码来源:BookQueryTest.php

示例9: getBookByName

function getBookByName($book_name)
{
    # Get book object (if possible)
    $book_object = BookQuery::create()->findOneByName($book_name);
    # Get book object by abbreviation (if necessary)
    if (!$book_object) {
        $book_abbreviation_object = BookAbbreviationQuery::create()->findOneByName($book_name);
        if ($book_abbreviation_object) {
            $book_object = $book_abbreviation_object->getBook();
        }
    }
    # Return book object
    return $book_object;
}
开发者ID:arneau,项目名称:defender-app,代码行数:14,代码来源:books.php

示例10: createMysqlQuery

 /**
  * Generates a MySQL select statement.
  *
  * @param string $searchKey user given search key
  * @return MySQL select statement
  */
 protected function createMysqlQuery()
 {
     $searchKey = $this->key->asText();
     $option = $this->key->getOption();
     $query = BookQuery::searchQuery($searchKey);
     if ($option == 'new') {
         $query .= ' order by created desc limit 7';
     } else {
         if ($option == 'random') {
             $query .= ' order by rand() limit 7';
         } else {
             $query .= ' order by author, title, price';
         }
     }
     return $query;
 }
开发者ID:BackupTheBerlios,项目名称:ubook-svn,代码行数:22,代码来源:LocalSearchBookList.php

示例11: testGetNbResults

 public function testGetNbResults()
 {
     BookQuery::create()->deleteAll();
     $pager = $this->getPager(4, 1);
     $this->assertEquals(0, $pager->getNbResults(), 'getNbResults() returns 0 when there are no results');
     $this->createBooks(5);
     $pager = $this->getPager(4, 1);
     $this->assertEquals(5, $pager->getNbResults(), 'getNbResults() returns the total number of results');
     $pager = $this->getPager(2, 1);
     $this->assertEquals(5, $pager->getNbResults(), 'getNbResults() returns the total number of results');
     $pager = $this->getPager(2, 2);
     $this->assertEquals(5, $pager->getNbResults(), 'getNbResults() returns the total number of results');
     $pager = $this->getPager(7, 6);
     $this->assertEquals(5, $pager->getNbResults(), 'getNbResults() returns the total number of results');
     $pager = $this->getPager(0, 0);
     $this->assertEquals(5, $pager->getNbResults(), 'getNbResults() returns the total number of results');
 }
开发者ID:RadioCampusFrance,项目名称:airtime,代码行数:17,代码来源:PropelModelPagerTest.php

示例12: getVersesByReference

function getVersesByReference($reference_string)
{
    # Get reference data
    $reference_data = getReferenceData($reference_string);
    # Get book object
    $book_object = BookQuery::create()->filterByName($reference_data['book'])->findOne();
    if (!$book_object) {
        return false;
    }
    # Get verses object
    $verses_object = VerseQuery::create()->filterByBook($book_object)->filterByChapterNumber($reference_data['chapter'])->_if($reference_data['verses'])->filterByVerseNumber($reference_data['verses'])->_endif()->find();
    if (!$verses_object) {
        return false;
    }
    # Return verses object
    return $verses_object;
}
开发者ID:arneau,项目名称:defender-app,代码行数:17,代码来源:verses.php

示例13: getPassageData

function getPassageData($reference_string, $bible_code = 'kjv')
{
    # Stop if no reference string provided
    if (!$reference_string) {
        return;
    }
    # Get reference data
    $reference_data = getReferenceData($reference_string);
    # Get bible object
    $bible_object = BibleQuery::create()->filterByCode($bible_code)->findOne();
    # Get book object
    $book_object = BookQuery::create()->filterByName($reference_data['book'])->findOne();
    # Define passage data
    $passage_data = ['bible' => ['code' => ['default' => $bible_object->getCode(), 'formatted' => strtoupper($bible_object->getCode())], 'id' => $bible_object->getId(), 'name' => $bible_object->getName()], 'book' => ['id' => $book_object->getId(), 'name' => $book_object->getName()], 'chapter' => ['number' => $reference_data['chapter']], 'reference' => ['string' => $reference_string], 'verses' => $reference_data['verses']];
    # Return passage data
    return $passage_data;
}
开发者ID:arneau,项目名称:defender-app,代码行数:17,代码来源:passages.php

示例14: testIsPrimary

 public function testIsPrimary()
 {
     $q = AuthorQuery::create()->joinBook();
     $joins = $q->getJoins();
     $join = $joins['Book'];
     $with = new ModelWith($join);
     $this->assertTrue($with->isPrimary(), 'A ModelWith initialized from a primary join is primary');
     $q = BookQuery::create()->joinAuthor()->joinReview();
     $joins = $q->getJoins();
     $join = $joins['Review'];
     $with = new ModelWith($join);
     $this->assertTrue($with->isPrimary(), 'A ModelWith initialized from a primary join is primary');
     $q = AuthorQuery::create()->join('Author.Book')->join('Book.Publisher');
     $joins = $q->getJoins();
     $join = $joins['Publisher'];
     $with = new ModelWith($join);
     $this->assertFalse($with->isPrimary(), 'A ModelWith initialized from a non-primary join is not primary');
 }
开发者ID:ketheriel,项目名称:ETVA,代码行数:18,代码来源:ModelWithTest.php

示例15: testCloneCopiesSelect

 public function testCloneCopiesSelect()
 {
     $bookQuery1 = BookQuery::create();
     $bookQuery1->select(array('Id', 'Title'));
     $bookQuery2 = clone $bookQuery1;
     $bookQuery2->select(array('ISBN', 'Price'));
     $this->assertEquals(array('Id', 'Title'), $bookQuery1->getSelect());
 }
开发者ID:nevalla,项目名称:Propel,代码行数:8,代码来源:ModelCriteriaTest.php


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