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


PHP map\BookTableMap類代碼示例

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


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

示例1: testAddSelectColumnsAlias

 public function testAddSelectColumnsAlias()
 {
     $c = new Criteria();
     BookTableMap::addSelectColumns($c, 'foo');
     $expected = array('foo.ID', 'foo.TITLE', 'foo.ISBN', 'foo.PRICE', 'foo.PUBLISHER_ID', 'foo.AUTHOR_ID');
     $this->assertEquals($expected, $c->getSelectColumns(), 'addSelectColumns() uses the second parameter as a table alias');
 }
開發者ID:kalaspuffar,項目名稱:php-orm-benchmark,代碼行數:7,代碼來源:GeneratedTableMapTest.php

示例2: testSetRelationMapRightAlias

 public function testSetRelationMapRightAlias()
 {
     $bookTable = BookTableMap::getTableMap();
     $join = new ModelJoin();
     $join->setTableMap($bookTable);
     $join->setRelationMap($bookTable->getRelation('Author'), null, 'a');
     $this->assertEquals(array(BookTableMap::COL_AUTHOR_ID), $join->getLeftColumns(), 'setRelationMap() automatically sets the left columns');
     $this->assertEquals(array('a.id'), $join->getRightColumns(), 'setRelationMap() automatically sets the right columns  using the right table alias');
 }
開發者ID:dracony,項目名稱:forked-php-orm-benchmark,代碼行數:9,代碼來源:ModelJoinTest.php

示例3: testDelete

 public function testDelete()
 {
     $books = PropelQuery::from('Propel\\Tests\\Bookstore\\Book')->setFormatter(ModelCriteria::FORMAT_ARRAY)->find();
     $books->delete();
     // check that the modifications are persisted
     BookTableMap::clearInstancePool();
     $books = PropelQuery::from('Propel\\Tests\\Bookstore\\Book')->find();
     $this->assertEquals(0, count($books));
 }
開發者ID:badelas,項目名稱:thelia,代碼行數:9,代碼來源:ArrayCollectionTest.php

示例4: testSerializeHydratedObject

 public function testSerializeHydratedObject()
 {
     $book = new Book();
     $book->setTitle('Foo3');
     $book->setISBN('1234');
     $book->save();
     BookTableMap::clearInstancePool();
     $book = BookQuery::create()->findOneByTitle('Foo3');
     $sb = serialize($book);
     $this->assertEquals($book, unserialize($sb));
 }
開發者ID:kalaspuffar,項目名稱:php-orm-benchmark,代碼行數:11,代碼來源:ActiveRecordSerializeTest.php

示例5: testDoCount

 public function testDoCount()
 {
     try {
         $c = new Criteria();
         $c->add(BookTableMap::ID, 12, ' BAD SQL');
         BookTableMap::addSelectColumns($c);
         $c->doCount();
         $this->fail('Missing expected exception on BAD SQL');
     } catch (PropelException $e) {
         $this->assertContains($this->getSql('[SELECT COUNT(*) FROM `book` WHERE book.ID BAD SQL:p1]'), $e->getMessage(), 'SQL query is written in the exception message');
     }
 }
開發者ID:kalaspuffar,項目名稱:php-orm-benchmark,代碼行數:12,代碼來源:TableMapExceptionsTest.php

示例6: testTranslateFieldName

 /**
  * Tests the Base[Object]TableMap::translateFieldName() method
  */
 public function testTranslateFieldName()
 {
     $types = array(TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM);
     $expecteds = array(TableMap::TYPE_PHPNAME => 'AuthorId', TableMap::TYPE_STUDLYPHPNAME => 'authorId', TableMap::TYPE_COLNAME => 'book.AUTHOR_ID', TableMap::TYPE_FIELDNAME => 'author_id', TableMap::TYPE_NUM => 5);
     foreach ($types as $fromType) {
         foreach ($types as $toType) {
             $name = $expecteds[$fromType];
             $expected = $expecteds[$toType];
             $result = BookTableMap::translateFieldName($name, $fromType, $toType);
             $this->assertEquals($expected, $result);
         }
     }
 }
開發者ID:robin850,項目名稱:Propel2,代碼行數:16,代碼來源:FieldnameRelatedTest.php

示例7: testApplyLimitDuplicateColumnNameWithColumn

 public function testApplyLimitDuplicateColumnNameWithColumn()
 {
     Propel::getServiceContainer()->setAdapter('oracle', new OracleAdapter());
     $c = new Criteria();
     $c->setDbName('oracle');
     BookTableMap::addSelectColumns($c);
     AuthorTableMap::addSelectColumns($c);
     $c->addAsColumn('BOOK_PRICE', BookTableMap::COL_PRICE);
     $c->setLimit(1);
     $params = [];
     $asColumns = $c->getAsColumns();
     $sql = $c->createSelectSql($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:disider,項目名稱:Propel2,代碼行數:15,代碼來源:OracleAdapterTest.php

示例8: testApplyLimitDuplicateColumnNameWithColumn

 public function testApplyLimitDuplicateColumnNameWithColumn()
 {
     Propel::getServiceContainer()->setAdapter('oracle', new OracleAdapter());
     $c = new Criteria();
     $c->setDbName('oracle');
     BookTableMap::addSelectColumns($c);
     AuthorTableMap::addSelectColumns($c);
     $c->addAsColumn('BOOK_PRICE', BookTableMap::PRICE);
     $c->setLimit(1);
     $params = array();
     $asColumns = $c->getAsColumns();
     $sql = $c->createSelectSql($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:kalaspuffar,項目名稱:php-orm-benchmark,代碼行數:15,代碼來源:OracleAdapterTest.php

示例9: testNeedsSelectAliases

 public function testNeedsSelectAliases()
 {
     $c = new Criteria();
     $this->assertFalse($c->needsSelectAliases(), 'Empty Criterias don\'t need aliases');
     $c = new Criteria();
     $c->addSelectColumn(BookTableMap::COL_ID);
     $c->addSelectColumn(BookTableMap::COL_TITLE);
     $this->assertFalse($c->needsSelectAliases(), 'Criterias with distinct column names don\'t need aliases');
     $c = new Criteria();
     BookTableMap::addSelectColumns($c);
     $this->assertFalse($c->needsSelectAliases(), 'Criterias with only the columns of a model don\'t need aliases');
     $c = new Criteria();
     $c->addSelectColumn(BookTableMap::COL_ID);
     $c->addSelectColumn(AuthorTableMap::COL_ID);
     $this->assertTrue($c->needsSelectAliases(), 'Criterias with common column names do need aliases');
 }
開發者ID:bondarovich,項目名稱:Propel2,代碼行數:16,代碼來源:TableMapTest.php

示例10: testSubQueryExplicit

 public function testSubQueryExplicit()
 {
     $subCriteria = new BookQuery();
     BookTableMap::addSelectColumns($subCriteria);
     $subCriteria->orderByTitle(Criteria::ASC);
     $c = new BookQuery();
     BookTableMap::addSelectColumns($c, 'subCriteriaAlias');
     $c->addSelectQuery($subCriteria, 'subCriteriaAlias', false);
     $c->groupBy('subCriteriaAlias.AuthorId');
     if ($this->isDb('pgsql')) {
         $sql = $this->getSql("SELECT subCriteriaAlias.id, subCriteriaAlias.title, subCriteriaAlias.isbn, subCriteriaAlias.price, subCriteriaAlias.publisher_id, subCriteriaAlias.author_id FROM (SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book ORDER BY book.title ASC) AS subCriteriaAlias GROUP BY subCriteriaAlias.author_id,subCriteriaAlias.id,subCriteriaAlias.title,subCriteriaAlias.isbn,subCriteriaAlias.price,subCriteriaAlias.publisher_id");
     } else {
         $sql = $this->getSql("SELECT subCriteriaAlias.id, subCriteriaAlias.title, subCriteriaAlias.isbn, subCriteriaAlias.price, subCriteriaAlias.publisher_id, subCriteriaAlias.author_id FROM (SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book ORDER BY book.title ASC) AS subCriteriaAlias GROUP BY subCriteriaAlias.author_id");
     }
     $params = array();
     $this->assertCriteriaTranslation($c, $sql, $params, 'addSubQueryCriteriaInFrom() combines two queries successfully');
 }
開發者ID:KyleGoslan,項目名稱:Huge-Propel,代碼行數:17,代碼來源:SubQueryTest.php

示例11: testSubQueryExplicit

 public function testSubQueryExplicit()
 {
     $subCriteria = new BookQuery();
     BookTableMap::addSelectColumns($subCriteria);
     $subCriteria->orderByTitle(Criteria::ASC);
     $c = new BookQuery();
     BookTableMap::addSelectColumns($c, 'subCriteriaAlias');
     $c->addSelectQuery($subCriteria, 'subCriteriaAlias', false);
     $c->groupBy('subCriteriaAlias.AuthorId');
     if (in_array($this->getDriver(), array('mysql'))) {
         $sql = "SELECT subCriteriaAlias.ID, subCriteriaAlias.TITLE, subCriteriaAlias.ISBN, subCriteriaAlias.PRICE, subCriteriaAlias.PUBLISHER_ID, subCriteriaAlias.AUTHOR_ID FROM (SELECT book.ID, book.TITLE, book.ISBN, book.PRICE, book.PUBLISHER_ID, book.AUTHOR_ID FROM `book` ORDER BY book.TITLE ASC) AS subCriteriaAlias GROUP BY subCriteriaAlias.AUTHOR_ID";
     } else {
         $sql = "SELECT subCriteriaAlias.ID, subCriteriaAlias.TITLE, subCriteriaAlias.ISBN, subCriteriaAlias.PRICE, subCriteriaAlias.PUBLISHER_ID, subCriteriaAlias.AUTHOR_ID FROM (SELECT book.ID, book.TITLE, book.ISBN, book.PRICE, book.PUBLISHER_ID, book.AUTHOR_ID FROM book ORDER BY book.TITLE ASC) AS subCriteriaAlias GROUP BY subCriteriaAlias.AUTHOR_ID";
     }
     $params = array();
     $this->assertCriteriaTranslation($c, $sql, $params, 'addSubQueryCriteriaInFrom() combines two queries successfully');
 }
開發者ID:robin850,項目名稱:Propel2,代碼行數:17,代碼來源:SubQueryTest.php

示例12: testSetterOneToManyWithExistingObjects

 public function testSetterOneToManyWithExistingObjects()
 {
     // Ensure no data
     BookQuery::create()->deleteAll();
     AuthorQuery::create()->deleteAll();
     for ($i = 0; $i < 3; $i++) {
         $b = new Book();
         $b->setTitle('Book ' . $i);
         $b->setISBN('FA404-' . $i);
         $b->save();
     }
     BookTableMap::clearInstancePool();
     $books = BookQuery::create()->find();
     $a = new Author();
     $a->setFirstName('Chuck');
     $a->setLastName('Norris');
     $a->setBooks($books);
     $a->save();
     $this->assertEquals(3, count($a->getBooks()));
     $this->assertEquals(1, AuthorQuery::create()->count());
     $this->assertEquals(3, BookQuery::create()->count());
     $i = 0;
     foreach ($a->getBooks() as $book) {
         $this->assertEquals('Book ' . $i++, $book->getTitle());
     }
 }
開發者ID:robin850,項目名稱:Propel2,代碼行數:26,代碼來源:GeneratedObjectTest.php

示例13: testDebugLog

 public function testDebugLog()
 {
     $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME);
     // save data to return to normal state after test
     $logger = $con->getLogger();
     $logMethods = $con->getLogMethods();
     $testLog = new Logger('debug');
     $handler = new LastMessageHandler();
     $testLog->pushHandler($handler);
     $con->setLogger($testLog);
     $con->setLogMethods(['exec', 'query', 'execute', 'beginTransaction', 'commit', 'rollBack']);
     $con->useDebug(true);
     $con->beginTransaction();
     // test transaction log
     $this->assertEquals('Begin transaction', $handler->latestMessage, 'PropelPDO logs begin transaction in debug mode');
     $con->commit();
     $this->assertEquals('Commit transaction', $handler->latestMessage, 'PropelPDO logs commit transaction in debug mode');
     $con->beginTransaction();
     $con->rollBack();
     $this->assertEquals('Rollback transaction', $handler->latestMessage, 'PropelPDO logs rollback transaction in debug mode');
     $con->beginTransaction();
     $handler->latestMessage = '';
     $con->beginTransaction();
     $this->assertEquals('', $handler->latestMessage, 'PropelPDO does not log nested begin transaction in debug mode');
     $con->commit();
     $this->assertEquals('', $handler->latestMessage, 'PropelPDO does not log nested commit transaction in debug mode');
     $con->beginTransaction();
     $con->rollBack();
     $this->assertEquals('', $handler->latestMessage, 'PropelPDO does not log nested rollback transaction in debug mode');
     $con->rollback();
     // test query log
     $con->beginTransaction();
     $c = new Criteria();
     $c->add(BookTableMap::COL_TITLE, 'Harry%s', Criteria::LIKE);
     $books = BookQuery::create(null, $c)->find($con);
     $latestExecutedQuery = $this->getSql("SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM book WHERE book.title LIKE 'Harry%s'");
     $this->assertEquals($latestExecutedQuery, $handler->latestMessage, 'PropelPDO logs queries and populates bound parameters in debug mode');
     BookTableMap::doDeleteAll($con);
     $latestExecutedQuery = $this->getSql("DELETE FROM book");
     $this->assertEquals($latestExecutedQuery, $handler->latestMessage, 'PropelPDO logs deletion queries in debug mode');
     $latestExecutedQuery = 'DELETE FROM book WHERE 1=1';
     $con->exec($latestExecutedQuery);
     $this->assertEquals($latestExecutedQuery, $handler->latestMessage, 'PropelPDO logs exec queries in debug mode');
     $con->commit();
     // return to normal state after test
     $con->setLogger($logger);
     $con->setLogMethods($logMethods);
 }
開發者ID:disider,項目名稱:Propel2,代碼行數:48,代碼來源:PropelPDOTest.php

示例14: testSetterCollectionWithExistingObjects

 public function testSetterCollectionWithExistingObjects()
 {
     // Ensure no data
     BookQuery::create()->deleteAll();
     BookClubListQuery::create()->deleteAll();
     BookListRelQuery::create()->deleteAll();
     for ($i = 0; $i < 3; $i++) {
         $b = new Book();
         $b->setTitle('Book ' . $i);
         $b->setIsbn($i);
         $b->save();
     }
     BookTableMap::clearInstancePool();
     $books = BookQuery::create()->find();
     $bookClubList = new BookClubList();
     $bookClubList->setGroupLeader('fabpot');
     $bookClubList->setBooks($books);
     $bookClubList->save();
     $this->assertEquals(3, count($bookClubList->getBooks()));
     $this->assertEquals(3, BookQuery::create()->count());
     $this->assertEquals(1, BookClubListQuery::create()->count());
     $this->assertEquals(3, BookListRelQuery::create()->count());
     $i = 0;
     foreach ($bookClubList->getBooks() as $book) {
         $this->assertEquals('Book ' . $i++, $book->getTitle());
     }
 }
開發者ID:disider,項目名稱:Propel2,代碼行數:27,代碼來源:GeneratedObjectRelTest.php

示例15: testPruneCompositeKey

 public function testPruneCompositeKey()
 {
     BookstoreDataPopulator::depopulate();
     BookstoreDataPopulator::populate();
     // save all books to make sure related objects are also saved - BookstoreDataPopulator keeps some unsaved
     $c = new ModelCriteria('bookstore', '\\Propel\\Tests\\Bookstore\\Book');
     $books = $c->find();
     foreach ($books as $book) {
         $book->save();
     }
     BookTableMap::clearInstancePool();
     $nbBookListRel = BookListRelQuery::create()->prune()->count();
     $this->assertEquals(2, $nbBookListRel, 'prune() does nothing when passed a null object');
     $testBookListRel = BookListRelQuery::create()->findOne();
     $nbBookListRel = BookListRelQuery::create()->prune($testBookListRel)->count();
     $this->assertEquals(1, $nbBookListRel, 'prune() removes an object from the result');
 }
開發者ID:kalaspuffar,項目名稱:php-orm-benchmark,代碼行數:17,代碼來源:QueryBuilderTest.php


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