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


PHP BookPeer::doCount方法代码示例

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


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

示例1: testDoSelect_Limit

 /**
  * Tests performing doSelect() and doSelectJoin() using LIMITs.
  */
 public function testDoSelect_Limit()
 {
     // 1) get the total number of items in a particular table
     $count = BookPeer::doCount(new Criteria());
     $this->assertTrue($count > 1, "Need more than 1 record in books table to perform this test.");
     $limitcount = $count - 1;
     $lc = new Criteria();
     $lc->setLimit($limitcount);
     $results = BookPeer::doSelect($lc);
     $this->assertEquals($limitcount, count($results), "Expected {$limitcount} results from BookPeer::doSelect()");
     // re-create it just to avoid side-effects
     $lc2 = new Criteria();
     $lc2->setLimit($limitcount);
     $results2 = BookPeer::doSelectJoinAuthor($lc2);
     $this->assertEquals($limitcount, count($results2), "Expected {$limitcount} results from BookPeer::doSelectJoinAuthor()");
 }
开发者ID:RafalFilipek,项目名称:Propel2,代码行数:19,代码来源:GeneratedPeerDoSelectTest.php

示例2: testScenarioUsingQuery


//.........这里部分代码省略.........
     $rev1->setReviewDate("08/09/2001");
     // will fail: reviewed_by column required
     $bk1->addReview($rev1);
     $ret2 = $bk1->validate();
     $this->assertFalse($ret2, 'validation failed');
     $failures2 = $bk1->getValidationFailures();
     $this->assertEquals(3, count($failures2), '3 validation messages were returned');
     $expectedKeys = array(AuthorPeer::LAST_NAME, BookPeer::TITLE, ReviewPeer::REVIEWED_BY);
     $this->assertEquals($expectedKeys, array_keys($failures2), 'correct columns failed');
     $bk2 = new Book();
     $bk2->setTitle("12345678901");
     // passes
     $auth2 = new Author();
     $auth2->setLastName("Blah");
     //passes
     $auth2->setEmail("some@body.com");
     //passes
     $auth2->setAge(50);
     //passes
     $bk2->setAuthor($auth2);
     $rev2 = new Review();
     $rev2->setReviewedBy("Me!");
     // passes
     $rev2->setStatus("new");
     // passes
     $bk2->addReview($rev2);
     $ret3 = $bk2->validate();
     $this->assertTrue($ret3, 'complex validation can pass');
     // Testing doCount() functionality
     // -------------------------------
     // old way
     $c = new Criteria();
     $records = BookPeer::doSelect($c);
     $count = BookPeer::doCount($c);
     $this->assertEquals($count, count($records), 'correct number of results');
     // new way
     $count = BookQuery::create()->count();
     $this->assertEquals($count, count($records), 'correct number of results');
     // Test many-to-many relationships
     // ---------------
     // init book club list 1 with 2 books
     $blc1 = new BookClubList();
     $blc1->setGroupLeader("Crazyleggs");
     $blc1->setTheme("Happiness");
     $brel1 = new BookListRel();
     $brel1->setBook($phoenix);
     $brel2 = new BookListRel();
     $brel2->setBook($dj);
     $blc1->addBookListRel($brel1);
     $blc1->addBookListRel($brel2);
     $blc1->save();
     $this->assertNotNull($blc1->getId(), 'BookClubList 1 was saved');
     // init book club list 2 with 1 book
     $blc2 = new BookClubList();
     $blc2->setGroupLeader("John Foo");
     $blc2->setTheme("Default");
     $brel3 = new BookListRel();
     $brel3->setBook($phoenix);
     $blc2->addBookListRel($brel3);
     $blc2->save();
     $this->assertNotNull($blc2->getId(), 'BookClubList 2 was saved');
     // re-fetch books and lists from db to be sure that nothing is cached
     $crit = new Criteria();
     $crit->add(BookPeer::ID, $phoenix->getId());
     $phoenix = BookPeer::doSelectOne($crit);
     $this->assertNotNull($phoenix, "book 'phoenix' has been re-fetched from db");
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:67,代码来源:BookstoreTest.php

示例3: boolTest

    // passes
    $bk2->addReview($rev2);
    $ret3 = $bk2->validate();
    print "Making sure complex validation can pass: ";
    print boolTest($ret3 === true);
} catch (Exception $e) {
    die("Error doing validation tests: " . $e->__toString());
}
// Test doCount()
//
try {
    print "\nTesting doCount() functionality\n";
    print "-------------------------------\n\n";
    $c = new Criteria();
    $records = BookPeer::doSelect($c);
    $count = BookPeer::doCount($c);
    print "Making sure correct number of results: ";
    print boolTest(count($records) === $count);
} catch (Exception $e) {
    die("Error deleting book: " . $e->__toString());
}
// Test many-to-many relationships
// ---------------
try {
    print "\nTesting many-to-many relationships\n";
    print "-----------------------------\n\n";
    // init book club list 1 with 2 books
    $blc1 = new BookClubList();
    $blc1->setGroupLeader("Crazyleggs");
    $blc1->setTheme("Happiness");
    $brel1 = new BookListRel();
开发者ID:yasirgit,项目名称:afids,代码行数:31,代码来源:bookstore-test.php

示例4: testDoCountJoin

 /**
  * Test doCountJoin*() methods.
  */
 public function testDoCountJoin()
 {
     BookPeer::doDeleteAll();
     for ($i = 0; $i < 25; $i++) {
         $b = new Book();
         $b->setTitle("Book {$i}");
         $b->setISBN("ISBN {$i}");
         $b->save();
     }
     $c = new Criteria();
     $totalCount = BookPeer::doCount($c);
     $this->assertEquals($totalCount, BookPeer::doCountJoinAuthor($c));
     $this->assertEquals($totalCount, BookPeer::doCountJoinPublisher($c));
 }
开发者ID:ketheriel,项目名称:ETVA,代码行数:17,代码来源:GeneratedPeerDoDeleteTest.php

示例5: testSpeed


//.........这里部分代码省略.........
     $bk2->setTitle("Don Juan");
     $ret = $bk2->validate();
     // Now trying some more complex validation.
     $auth1 = new Author();
     $auth1->setFirstName("Hans");
     // last name required; will fail
     $bk1->setAuthor($auth1);
     $rev1 = new Review();
     $rev1->setReviewDate("08/09/2001");
     // will fail: reviewed_by column required
     $bk1->addReview($rev1);
     $ret2 = $bk1->validate();
     $bk2 = new Book();
     $bk2->setTitle("12345678901");
     // passes
     $auth2 = new Author();
     $auth2->setLastName("Blah");
     //passes
     $auth2->setEmail("some@body.com");
     //passes
     $auth2->setAge(50);
     //passes
     $bk2->setAuthor($auth2);
     $rev2 = new Review();
     $rev2->setReviewedBy("Me!");
     // passes
     $rev2->setStatus("new");
     // passes
     $bk2->addReview($rev2);
     $ret3 = $bk2->validate();
     // Testing doCount() functionality
     // -------------------------------
     $c = new Criteria();
     $count = BookPeer::doCount($c);
     // Testing many-to-many relationships
     // ----------------------------------
     // init book club list 1 with 2 books
     $blc1 = new BookClubList();
     $blc1->setGroupLeader("Crazyleggs");
     $blc1->setTheme("Happiness");
     $brel1 = new BookListRel();
     $brel1->setBook($phoenix);
     $brel2 = new BookListRel();
     $brel2->setBook($dj);
     $blc1->addBookListRel($brel1);
     $blc1->addBookListRel($brel2);
     $blc1->save();
     // init book club list 2 with 1 book
     $blc2 = new BookClubList();
     $blc2->setGroupLeader("John Foo");
     $blc2->setTheme("Default");
     $brel3 = new BookListRel();
     $brel3->setBook($phoenix);
     $blc2->addBookListRel($brel3);
     $blc2->save();
     // re-fetch books and lists from db to be sure that nothing is cached
     $crit = new Criteria();
     $crit->add(BookPeer::ID, $phoenix->getId());
     $phoenix = BookPeer::doSelectOne($crit);
     $crit = new Criteria();
     $crit->add(BookClubListPeer::ID, $blc1->getId());
     $blc1 = BookClubListPeer::doSelectOne($crit);
     $crit = new Criteria();
     $crit->add(BookClubListPeer::ID, $blc2->getId());
     $blc2 = BookClubListPeer::doSelectOne($crit);
     $relCount = $phoenix->countBookListRels();
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:67,代码来源:speed.php

示例6: countBooks

 /**
  * Returns the number of related Book objects.
  *
  * @param      Criteria $criteria
  * @param      boolean $distinct
  * @param      PropelPDO $con
  * @return     int Count of related Book objects.
  * @throws     PropelException
  */
 public function countBooks(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
 {
     if ($criteria === null) {
         $criteria = new Criteria(AuthorPeer::DATABASE_NAME);
     } else {
         $criteria = clone $criteria;
     }
     if ($distinct) {
         $criteria->setDistinct();
     }
     $count = null;
     if ($this->collBooks === null) {
         if ($this->isNew()) {
             $count = 0;
         } else {
             $criteria->add(BookPeer::AUTHOR_ID, $this->id);
             $count = BookPeer::doCount($criteria, false, $con);
         }
     } else {
         // criteria has no effect for a new object
         if (!$this->isNew()) {
             // the following code is to determine if a new query is
             // called for.  If the criteria is the same as the last
             // one, just return count of the collection.
             $criteria->add(BookPeer::AUTHOR_ID, $this->id);
             if (!isset($this->lastBookCriteria) || !$this->lastBookCriteria->equals($criteria)) {
                 $count = BookPeer::doCount($criteria, false, $con);
             } else {
                 $count = count($this->collBooks);
             }
         } else {
             $count = count($this->collBooks);
         }
     }
     return $count;
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:45,代码来源:BaseAuthor.php


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