當前位置: 首頁>>代碼示例>>PHP>>正文


PHP AuthorPeer類代碼示例

本文整理匯總了PHP中AuthorPeer的典型用法代碼示例。如果您正苦於以下問題:PHP AuthorPeer類的具體用法?PHP AuthorPeer怎麽用?PHP AuthorPeer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了AuthorPeer類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: check_tables_empty

function check_tables_empty()
{
    try {
        print "\nChecking to see that tables are empty\n";
        print "-------------------------------------\n\n";
        print "Ensuring that there are no records in [author] table: ";
        $res = AuthorPeer::doSelect(new Criteria());
        print boolTest(empty($res));
        print "Ensuring that there are no records in [publisher] table: ";
        $res2 = PublisherPeer::doSelect(new Criteria());
        print boolTest(empty($res2));
        print "Ensuring that there are no records in [book] table: ";
        $res3 = AuthorPeer::doSelect(new Criteria());
        print boolTest(empty($res3));
        print "Ensuring that there are no records in [review] table: ";
        $res4 = ReviewPeer::doSelect(new Criteria());
        print boolTest(empty($res4));
        print "Ensuring that there are no records in [media] table: ";
        $res5 = MediaPeer::doSelect(new Criteria());
        print boolTest(empty($res5));
        print "Ensuring that there are no records in [book_club_list] table: ";
        $res6 = BookClubListPeer::doSelect(new Criteria());
        print boolTest(empty($res6));
        print "Ensuring that there are no records in [book_x_list] table: ";
        $res7 = BookListRelPeer::doSelect(new Criteria());
        print boolTest(empty($res7));
        return empty($res) && empty($res2) && empty($res3) && empty($res4) && empty($res5);
    } catch (Exception $e) {
        die("Error ensuring tables were empty: " . $e->__toString());
    }
}
開發者ID:yasirgit,項目名稱:afids,代碼行數:31,代碼來源:bookstore-test.php

示例2: tearDown

 /**
  * This is run after each unit test.  It empties the database.
  */
 protected function tearDown()
 {
     BookstoreDataPopulator::depopulate();
     $this->assertEquals(0, count(BookPeer::doSelect(new Criteria())), "Expect book table to be empty.");
     $this->assertEquals(0, count(AuthorPeer::doSelect(new Criteria())), "Expect author table to be empty.");
     $this->assertEquals(0, count(PublisherPeer::doSelect(new Criteria())), "Expect publisher table to be empty.");
     $this->assertEquals(0, count(ReviewPeer::doSelect(new Criteria())), "Expect review table to be empty.");
     $this->assertEquals(0, count(MediaPeer::doSelect(new Criteria())), "Expect media table to be empty.");
     $this->assertEquals(0, count(BookstoreEmployeePeer::doSelect(new Criteria())), "Expect bookstore_employee table to be empty.");
     $this->assertEquals(0, count(BookstoreEmployeeAccountPeer::doSelect(new Criteria())), "Expect bookstore_employee_account table to be empty.");
     $this->assertEquals(0, count(BookstoreSalePeer::doSelect(new Criteria())), "Expect bookstore_sale table to be empty.");
     BookPeer::clearInstancePool();
     $this->assertEquals(0, count(BookPeer::$instances), "Expected 0 Book instances after clearInstancePool()");
     AuthorPeer::clearInstancePool();
     $this->assertEquals(0, count(AuthorPeer::$instances), "Expected 0 Author instances after clearInstancePool()");
     PublisherPeer::clearInstancePool();
     $this->assertEquals(0, count(PublisherPeer::$instances), "Expected 0 Publisher instances after clearInstancePool()");
     ReviewPeer::clearInstancePool();
     $this->assertEquals(0, count(ReviewPeer::$instances), "Expected 0 Review instances after clearInstancePool()");
     MediaPeer::clearInstancePool();
     $this->assertEquals(0, count(MediaPeer::$instances), "Expected 0 Media instances after clearInstancePool()");
     BookstoreEmployeePeer::clearInstancePool();
     $this->assertEquals(0, count(BookstoreEmployeePeer::$instances), "Expected 0 BookstoreEmployee instances after clearInstancePool()");
     BookstoreEmployeeAccountPeer::clearInstancePool();
     $this->assertEquals(0, count(BookstoreEmployeeAccountPeer::$instances), "Expected 0 BookstoreEmployeeAccount instances after clearInstancePool()");
     BookstoreSalePeer::clearInstancePool();
     $this->assertEquals(0, count(BookstoreSalePeer::$instances), "Expected 0 BookstoreSale instances after clearInstancePool()");
     parent::tearDown();
 }
開發者ID:JimmyVB,項目名稱:Symfony-v1.2,代碼行數:32,代碼來源:BookstoreTestBase.php

示例3: executeIndex

 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     # Recently added
     $c = new Criteria();
     $c->addDescendingOrderByColumn(PluginPeer::CREATED_AT);
     $c->setLimit(6);
     $this->recent = PluginPeer::doSelect($c);
     # Most downloaded
     $c = new Criteria();
     $c->addDescendingOrderByColumn(PluginPeer::DOWNLOADS_COUNT);
     $c->setLimit(3);
     $this->hot = PluginPeer::doSelect($c);
     # Tags
     $c = new Criteria();
     $c->addDescendingOrderByColumn(TermPeer::COUNT);
     $c->setLimit(10);
     $this->terms = TermPeer::retrieveTags($c);
     # Authors
     $c = new Criteria();
     $c->addDescendingOrderByColumn(AuthorPeer::LOGGED_AT);
     $c->setLimit(6);
     // if ($this->getUser()->isAuthenticated())
     // 	$c->add(AuthorPeer::ID, $this->getUser()->getId(), Criteria::NOT_EQUAL);
     $this->authors = AuthorPeer::doSelect($c);
 }
開發者ID:pkdevbox,項目名稱:mootools-forge,代碼行數:30,代碼來源:actions.class.php

示例4: emptyTables

 protected function emptyTables()
 {
     $res1 = AuthorPeer::doDeleteAll();
     $res2 = PublisherPeer::doDeleteAll();
     $res3 = AuthorPeer::doDeleteAll();
     $res4 = ReviewPeer::doDeleteAll();
     $res5 = MediaPeer::doDeleteAll();
     $res6 = BookClubListPeer::doDeleteAll();
     $res7 = BookListRelPeer::doDeleteAll();
 }
開發者ID:dracony,項目名稱:forked-php-orm-benchmark,代碼行數:10,代碼來源:speed.php

示例5: runComplexQuery

 function runComplexQuery($i)
 {
     $c = new Criteria();
     $cton1 = $c->getNewCriterion(AuthorPeer::ID, $this->authors[array_rand($this->authors)], Criteria::GREATER_THAN);
     $cton2 = $c->getNewCriterion(AuthorPeer::FIRST_NAME, '(' . AuthorPeer::FIRST_NAME . '||' . AuthorPeer::LAST_NAME . ') =' . $this->con->quote('John Doe'), Criteria::CUSTOM);
     $cton1->addOr($cton2);
     $c->add($cton1);
     $c->setLimit(5);
     AuthorPeer::doCount($c, $this->con);
 }
開發者ID:dracony,項目名稱:forked-php-orm-benchmark,代碼行數:10,代碼來源:Propel14TestSuite.php

示例6: testApplyLimitDuplicateColumnName

 public function testApplyLimitDuplicateColumnName()
 {
     Propel::setDb('oracle', new DBOracle());
     $c = new Criteria();
     $c->setDbName('oracle');
     BookPeer::addSelectColumns($c);
     AuthorPeer::addSelectColumns($c);
     $c->setLimit(1);
     $params = array();
     $sql = BasePeer::createSelectSql($c, $params);
     $this->assertEquals('SELECT B.* FROM (SELECT A.*, rownum AS PROPEL_ROWNUM FROM (SELECT book.ID AS book_ID, book.TITLE AS book_TITLE, book.ISBN AS book_ISBN, book.PRICE AS book_PRICE, book.PUBLISHER_ID AS book_PUBLISHER_ID, book.AUTHOR_ID AS book_AUTHOR_ID, author.ID AS author_ID, author.FIRST_NAME AS author_FIRST_NAME, author.LAST_NAME AS author_LAST_NAME, author.EMAIL AS author_EMAIL, author.AGE AS author_AGESELECT book.ID, book.TITLE, book.ISBN, book.PRICE, book.PUBLISHER_ID, book.AUTHOR_ID, author.ID, author.FIRST_NAME, author.LAST_NAME, author.EMAIL, author.AGE FROM book, author) A ) B WHERE  B.PROPEL_ROWNUM <= 1', $sql, 'applyLimit() creates a subselect with aliased column names when a duplicate column name is found');
 }
開發者ID:RadioCampusFrance,項目名稱:airtime,代碼行數:12,代碼來源:DBOracleTest.php

示例7: testApplyLimitDuplicateColumnNameWithColumn

 public function testApplyLimitDuplicateColumnNameWithColumn()
 {
     Propel::setDb('oracle', new DBOracle());
     $c = new Criteria();
     $c->setDbName('oracle');
     BookPeer::addSelectColumns($c);
     AuthorPeer::addSelectColumns($c);
     $c->addAsColumn('BOOK_PRICE', BookPeer::PRICE);
     $c->setLimit(1);
     $params = array();
     $asColumns = $c->getAsColumns();
     $sql = BasePeer::createSelectSql($c, $params);
     $this->assertEquals('SELECT B.* FROM (SELECT A.*, rownum AS PROPEL_ROWNUM FROM (SELECT book.ID AS ORA_COL_ALIAS_0, book.TITLE AS ORA_COL_ALIAS_1, book.ISBN AS ORA_COL_ALIAS_2, book.PRICE AS ORA_COL_ALIAS_3, book.PUBLISHER_ID AS ORA_COL_ALIAS_4, book.AUTHOR_ID AS ORA_COL_ALIAS_5, author.ID AS ORA_COL_ALIAS_6, author.FIRST_NAME AS ORA_COL_ALIAS_7, author.LAST_NAME AS ORA_COL_ALIAS_8, author.EMAIL AS ORA_COL_ALIAS_9, author.AGE AS ORA_COL_ALIAS_10, book.PRICE AS BOOK_PRICE FROM book, author) A ) B WHERE  B.PROPEL_ROWNUM <= 1', $sql, 'applyLimit() creates a subselect with aliased column names when a duplicate column name is found');
     $this->assertEquals($asColumns, $c->getAsColumns(), 'createSelectSql supplementary add alias column');
 }
開發者ID:shelsonjava,項目名稱:datawrapper,代碼行數:15,代碼來源:DBOracleTest.php

示例8: getValues

 public function getValues()
 {
     $map = call_user_func(array($this->peername, 'getPhpNameMap'));
     $c = new Criteria();
     $c->clearSelectColumns();
     foreach (array($this->label, $this->value) as $arr) {
         foreach ($arr['members'] as $member) {
             if (is_array($member)) {
                 foreach ($member as $member) {
                     $c->addSelectColumn(constant($this->peername . '::' . $map[$member]));
                 }
             } else {
                 $c->addSelectColumn(constant($this->peername . '::' . $map[$member]));
             }
         }
     }
     if (isset($this->label['initial']) or isset($this->value['initial'])) {
         $label = isset($this->label['initial']) ? $this->label['initial'] : '';
         $value = isset($this->value['initial']) ? $this->value['initial'] : '';
         $result[] = array('value' => $value, 'label' => $label);
     }
     $rs = AuthorPeer::doSelectStmt($c);
     $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     while ($rs->next()) {
         $row = $rs->getRow();
         foreach (array('label', 'value') as $key) {
             $arr = $this->{$key};
             $params = array($arr['mask']);
             foreach ($arr['members'] as $member) {
                 if (is_array($member)) {
                     foreach ($member as $member) {
                         $field_name = strtolower($map[$member]);
                         // TODO is this always true?
                         $params[] = $row[$field_name];
                     }
                 } else {
                     $field_name = strtolower($map[$member]);
                     // TODO is this always true?
                     $params[] = $row[$field_name];
                 }
             }
             ${$key} = call_user_func_array('sprintf', $params);
             $tmp[$key] = ${$key};
         }
         $result[] = $tmp;
     }
     return $result;
 }
開發者ID:dracony,項目名稱:forked-php-orm-benchmark,代碼行數:48,代碼來源:Propel.php

示例9: setUp

 protected function setUp()
 {
     parent::setUp();
     BookstoreDataPopulator::populate();
     $cr = new Criteria();
     $cr->add(AuthorPeer::LAST_NAME, "Rowling");
     $cr->add(AuthorPeer::FIRST_NAME, "J.K.");
     $rowling = AuthorPeer::doSelectOne($cr);
     $this->authorId = $rowling->getId();
     $book = new Book();
     $book->setTitle("Harry Potter and the Philosopher's Stone");
     $book->setISBN("1234");
     $book->setAuthor($rowling);
     $book->save();
     $this->books[] = $book->getId();
     $book = new Book();
     $book->setTitle("Harry Potter and the Chamber of Secrets");
     $book->setISBN("1234");
     $book->setAuthor($rowling);
     $book->save();
     $this->books[] = $book->getId();
     $book = new Book();
     $book->setTitle("Harry Potter and the Prisoner of Azkaban");
     $book->setISBN("1234");
     $book->setAuthor($rowling);
     $book->save();
     $this->books[] = $book->getId();
     $book = new Book();
     $book->setTitle("Harry Potter and the Goblet of Fire");
     $book->setISBN("1234");
     $book->setAuthor($rowling);
     $book->save();
     $this->books[] = $book->getId();
     $book = new Book();
     $book->setTitle("Harry Potter and the Half-Blood Prince");
     $book->setISBN("1234");
     $book->setAuthor($rowling);
     $book->save();
     $this->books[] = $book->getId();
     $book = new Book();
     $book->setTitle("Harry Potter and the Deathly Hallows");
     $book->setISBN("1234");
     $book->setAuthor($rowling);
     $book->save();
     $this->books[] = $book->getId();
 }
開發者ID:dracony,項目名稱:forked-php-orm-benchmark,代碼行數:46,代碼來源:PropelPagerTest.php

示例10: doClean

 /**
  * @see sfValidatorBase
  */
 protected function doClean($values)
 {
     if (is_null($values)) {
         $values = array();
     }
     if (!is_array($values)) {
         throw new InvalidArgumentException('You must pass an array parameter to the clean() method');
     }
     $loginValue = isset($values[$this->getOption('login_field')]) ? $values[$this->getOption('login_field')] : null;
     $passwordValue = isset($values[$this->getOption('password_field')]) ? $values[$this->getOption('password_field')] : null;
     if (!$loginValue) {
         return false;
     }
     $valid = AuthorPeer::retrieveByEmailAndPassword($loginValue, sha1($passwordValue));
     if (!$valid) {
         $error = new sfValidatorError($this, 'invalid', array('login_field' => $loginValue, 'password_field' => $passwordValue));
         if ($this->getOption('throw_global_error')) {
             throw $error;
         }
         throw new sfValidatorErrorSchema($this, array($this->getOption('login_field') => $error));
     }
     return $values;
 }
開發者ID:pkdevbox,項目名稱:mootools-forge,代碼行數:26,代碼來源:appValidatorSchemaLogin.class.php

示例11: testReloadDeep

 /**
  * Test reload(deep=true) method.
  */
 public function testReloadDeep()
 {
     // arbitrary book
     $b = BookPeer::doSelectOne(new Criteria());
     // arbitrary, different author
     $c = new Criteria();
     $c->add(AuthorPeer::ID, $b->getAuthorId(), Criteria::NOT_EQUAL);
     $a = AuthorPeer::doSelectOne($c);
     $origAuthor = $b->getAuthor();
     $b->setAuthor($a);
     $this->assertNotEquals($origAuthor, $b->getAuthor(), "Expected just-set object to be different from obj from DB");
     $this->assertTrue($b->isModified());
     $b->reload($deep = true);
     $this->assertEquals($origAuthor, $b->getAuthor(), "Expected object in DB to be restored");
     $this->assertFalse($a->isModified());
 }
開發者ID:JimmyVB,項目名稱:Symfony-v1.2,代碼行數:19,代碼來源:GeneratedObjectTest.php

示例12: testUseFkQueryTwiceTwoAliases

 public function testUseFkQueryTwiceTwoAliases()
 {
     $q = BookQuery::create()->useAuthorQuery('a')->filterByFirstName('Leo')->endUse()->useAuthorQuery('b')->filterByLastName('Tolstoi')->endUse();
     $join1 = new ModelJoin();
     $join1->setJoinType(Criteria::LEFT_JOIN);
     $join1->setTableMap(AuthorPeer::getTableMap());
     $join1->setRelationMap(BookPeer::getTableMap()->getRelation('Author'), null, 'a');
     $join1->setRelationAlias('a');
     $join2 = new ModelJoin();
     $join2->setJoinType(Criteria::LEFT_JOIN);
     $join2->setTableMap(AuthorPeer::getTableMap());
     $join2->setRelationMap(BookPeer::getTableMap()->getRelation('Author'), null, 'b');
     $join2->setRelationAlias('b');
     $q1 = BookQuery::create()->addAlias('a', AuthorPeer::TABLE_NAME)->addJoinObject($join1, 'a')->add('a.FIRST_NAME', 'Leo', Criteria::EQUAL)->addAlias('b', AuthorPeer::TABLE_NAME)->addJoinObject($join2, 'b')->add('b.LAST_NAME', 'Tolstoi', Criteria::EQUAL);
     $this->assertTrue($q->equals($q1), 'useFkQuery() called twice on the same relation with two aliases creates two joins');
 }
開發者ID:shelsonjava,項目名稱:datawrapper,代碼行數:16,代碼來源:QueryBuilderTest.php

示例13: testObjectInstances

 public function testObjectInstances()
 {
     $sample = BookPeer::doSelectOne(new Criteria());
     $samplePk = $sample->getPrimaryKey();
     // 1) make sure consecutive calls to retrieveByPK() return the same object.
     $b1 = BookPeer::retrieveByPK($samplePk);
     $b2 = BookPeer::retrieveByPK($samplePk);
     $sampleval = md5(microtime());
     $this->assertTrue($b1 === $b2, "Expected object instances to match for calls with same retrieveByPK() method signature.");
     // 2) make sure that calls to doSelect also return references to the same objects.
     $allbooks = BookPeer::doSelect(new Criteria());
     foreach ($allbooks as $testb) {
         if ($testb->getPrimaryKey() == $b1->getPrimaryKey()) {
             $this->assertTrue($testb === $b1, "Expected same object instance from doSelect() as from retrieveByPK()");
         }
     }
     // 3) test fetching related objects
     $book = BookPeer::retrieveByPK($samplePk);
     $bookauthor = $book->getAuthor();
     $author = AuthorPeer::retrieveByPK($bookauthor->getId());
     $this->assertTrue($bookauthor === $author, "Expected same object instance when calling fk object accessor as retrieveByPK()");
     // 4) test a doSelectJoin()
     $morebooks = BookPeer::doSelectJoinAuthor(new Criteria());
     for ($i = 0, $j = 0; $j < count($morebooks); $i++, $j++) {
         $testb1 = $allbooks[$i];
         $testb2 = $allbooks[$j];
         $this->assertTrue($testb1 === $testb2, "Expected the same objects from consecutive doSelect() calls.");
         // we could probably also test this by just verifying that $book & $testb are the same
         if ($testb1->getPrimaryKey() === $book) {
             $this->assertTrue($book->getAuthor() === $testb1->getAuthor(), "Expected same author object in calls to pkey-matching books.");
         }
     }
     // 5) test creating a new object, saving it, and then retrieving that object (should all be same instance)
     $b = new BookstoreEmployee();
     $b->setName("Testing");
     $b->setJobTitle("Testing");
     $b->save();
     $empId = $b->getId();
     $this->assertSame($b, BookstoreEmployeePeer::retrieveByPK($empId), "Expected newly saved object to be same instance as pooled.");
 }
開發者ID:RafalFilipek,項目名稱:Propel2,代碼行數:40,代碼來源:GeneratedPeerDoSelectTest.php

示例14: clearCache

 function clearCache()
 {
     BookPeer::clearInstancePool();
     AuthorPeer::clearInstancePool();
 }
開發者ID:dracony,項目名稱:forked-php-orm-benchmark,代碼行數:5,代碼來源:Propel17TestSuite.php

示例15: 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()->setFormatter(ModelCriteria::FORMAT_ARRAY)->joinWith('Review')->findPk($pk, $con);
     $reviews = $book['Reviews'];
     $this->assertEquals(2, count($reviews), 'Related objects are correctly hydrated');
 }
開發者ID:keneanung,項目名稱:gw2spidy,代碼行數:14,代碼來源:PropelArrayFormatterWithTest.php


注:本文中的AuthorPeer類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。