• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP BookQuery类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了BookQuery类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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 = '[email protected] (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


示例16: testPopulateRelationManyToOne

 public function testPopulateRelationManyToOne()
 {
     $con = Propel::getConnection();
     AuthorPeer::clearInstancePool();
     BookPeer::clearInstancePool();
     $books = BookQuery::create()->find($con);
     $count = $con->getQueryCount();
     $books->populateRelation('Author', null, $con);
     foreach ($books as $book) {
         $author = $book->getAuthor();
     }
     $this->assertEquals($count + 1, $con->getQueryCount(), 'populateRelation() populates a many-to-one relationship with a single supplementary query');
 }
开发者ID:keneanung,项目名称:gw2spidy,代码行数:13,代码来源:PropelObjectCollectionWithFixturesTest.php


示例17: testHooksCall

 public function testHooksCall()
 {
     AuthorQuery::create()->deleteAll();
     BookQuery::create()->deleteAll();
     $author = new CountableAuthor();
     $author->setFirstName('Foo');
     $author->setLastName('Bar');
     $book = new Book();
     $book->setTitle('A title');
     $book->setIsbn('13456');
     $author->addBook($book);
     $author->save();
     $this->assertEquals(1, AuthorQuery::create()->count());
     $this->assertEquals(1, BookQuery::create()->count());
     $this->assertEquals(1, $author->nbCallPreSave);
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:16,代码来源:GeneratedObjectTest.php


示例18: testFindPkWithOneToMany

 public function testFindPkWithOneToMany()
 {
     BookstoreDataPopulator::populate();
     BookPeer::clearInstancePool();
     AuthorPeer::clearInstancePool();
     ReviewPeer::clearInstancePool();
     $con = Propel::getConnection(BookPeer::DATABASE_NAME);
     $book = BookQuery::create()->findOneByTitle('Harry Potter and the Order of the Phoenix', $con);
     $pk = $book->getPrimaryKey();
     BookPeer::clearInstancePool();
     $book = BookQuery::create()->joinWith('Review')->findPk($pk, $con);
     $count = $con->getQueryCount();
     $reviews = $book->getReviews();
     $this->assertEquals($count, $con->getQueryCount(), 'with() hydrates the related objects to save a query ');
     $this->assertEquals(2, count($reviews), 'Related objects are correctly hydrated');
 }
开发者ID:halfer,项目名称:Meshing,代码行数:16,代码来源:PropelObjectFormatterWithTest.php


示例19: testSetterOneToManyReplacesOldObjectsByNewObjects

 public function testSetterOneToManyReplacesOldObjectsByNewObjects()
 {
     // Ensure no data
     BookQuery::create()->deleteAll();
     AuthorQuery::create()->deleteAll();
     $books = new PropelObjectCollection();
     foreach (array('foo', 'bar') as $title) {
         $b = new Book();
         $b->setTitle($title);
         $books[] = $b;
     }
     $a = new Author();
     $a->setBooks($books);
     $a->save();
     $books = $a->getBooks();
     $this->assertEquals('foo', $books[0]->getTitle());
     $this->assertEquals('bar', $books[1]->getTitle());
     $books = new PropelObjectCollection();
     foreach (array('bam', 'bom') as $title) {
         $b = new Book();
         $b->setTitle($title);
         $books[] = $b;
     }
     $a->setBooks($books);
     $a->save();
     $books = $a->getBooks();
     $this->assertEquals('bam', $books[0]->getTitle());
     $this->assertEquals('bom', $books[1]->getTitle());
     $this->assertEquals(1, AuthorQuery::create()->count());
     $this->assertEquals(2, BookQuery::create()->count());
 }
开发者ID:ratibus,项目名称:Crew,代码行数:31,代码来源:GeneratedObjectTest.php


示例20: testClone

 public function testClone()
 {
     $bookQuery1 = BookQuery::create()->filterByPrice(1);
     $bookQuery2 = clone $bookQuery1;
     $bookQuery2->filterByPrice(2);
     $params = array();
     $sql = BasePeer::createSelectSql($bookQuery1, $params);
     $this->assertEquals('SELECT  FROM `book` WHERE book.PRICE=:p1', $sql, 'conditions applied on a cloned query don\'t get applied on the original query');
 }
开发者ID:ketheriel,项目名称:ETVA,代码行数:9,代码来源:ModelCriteriaTest.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Booking类代码示例发布时间:2022-05-23
下一篇:
PHP BookPeer类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap