本文整理汇总了PHP中BookPeer类的典型用法代码示例。如果您正苦于以下问题:PHP BookPeer类的具体用法?PHP BookPeer怎么用?PHP BookPeer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BookPeer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tearDown
protected function tearDown()
{
parent::tearDown();
$cr = new Criteria();
$cr->add(BookPeer::ID, $this->books, Criteria::IN);
BookPeer::doDelete($cr);
}
示例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();
}
示例3: testAddSelectColumnsAlias
public function testAddSelectColumnsAlias()
{
$c = new Criteria();
BookPeer::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');
}
示例4: runJoinSearch
function runJoinSearch($i)
{
$c = new Criteria();
$c->add(BookPeer::TITLE, 'Hello' . $i, Criteria::EQUAL);
$c->setLimit(1);
$books = BookPeer::doSelectJoinAuthor($c, $this->con);
$book = $books[0];
}
示例5: testGetLastQueryMoreThanTenArgs
public function testGetLastQueryMoreThanTenArgs()
{
$con = Propel::getConnection(BookPeer::DATABASE_NAME);
$c = new Criteria();
$c->add(BookPeer::ID, array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), Criteria::IN);
$books = BookPeer::doSelect($c, $con);
$expected = "SELECT book.ID, book.TITLE, book.ISBN, book.PRICE, book.PUBLISHER_ID, book.AUTHOR_ID FROM `book` WHERE book.ID IN (1,1,1,1,1,1,1,1,1,1,1,1)";
$this->assertEquals($expected, $con->getLastExecutedQuery(), 'PropelPDO correctly replaces arguments in queries');
}
示例6: testDelete
public function testDelete()
{
$books = PropelQuery::from('Book')->setFormatter(ModelCriteria::FORMAT_ARRAY)->find();
$books->delete();
// check that the modifications are persisted
BookPeer::clearInstancePool();
$books = PropelQuery::from('Book')->find();
$this->assertEquals(0, count($books));
}
示例7: testSetRelationMapRightAlias
public function testSetRelationMapRightAlias()
{
$bookTable = BookPeer::getTableMap();
$join = new ModelJoin();
$join->setTableMap($bookTable);
$join->setRelationMap($bookTable->getRelation('Author'), null, 'a');
$this->assertEquals(array(BookPeer::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');
}
示例8: 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));
}
示例9: testDoCount
public function testDoCount()
{
try {
$c = new Criteria();
$c->add(BookPeer::ID, 12, ' BAD SQL');
BookPeer::addSelectColumns($c);
BasePeer::doCount($c);
} catch (PropelException $e) {
$this->assertContains('[SELECT COUNT(*) FROM `book` WHERE book.ID BAD SQL:p1]', $e->getMessage(), 'SQL query is written in the exception message');
}
}
示例10: 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');
}
示例11: testSubQueryExplicit
public function testSubQueryExplicit()
{
$subCriteria = new BookQuery();
BookPeer::addSelectColumns($subCriteria);
$subCriteria->orderByTitle(Criteria::ASC);
$c = new BookQuery();
BookPeer::addSelectColumns($c, 'subCriteriaAlias');
$c->addSelectQuery($subCriteria, 'subCriteriaAlias', false);
$c->groupBy('subCriteriaAlias.AuthorId');
$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');
}
示例12: testTranslateFieldName
/**
* Tests the Base[Object]Peer::translateFieldName() method
*/
public function testTranslateFieldName()
{
$types = array(BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM);
$expecteds = array(BasePeer::TYPE_PHPNAME => 'AuthorId', BasePeer::TYPE_STUDLYPHPNAME => 'authorId', BasePeer::TYPE_COLNAME => 'book.AUTHOR_ID', BasePeer::TYPE_FIELDNAME => 'author_id', BasePeer::TYPE_NUM => 5);
foreach ($types as $fromType) {
foreach ($types as $toType) {
$name = $expecteds[$fromType];
$expected = $expecteds[$toType];
$result = BookPeer::translateFieldName($name, $fromType, $toType);
$this->assertEquals($expected, $result);
}
}
}
示例13: 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');
}
示例14: testMultipleFunctionInCriteria
/**
* @link http://propel.phpdb.org/trac/ticket/425
*/
public function testMultipleFunctionInCriteria()
{
$db = Propel::getDB(BookPeer::DATABASE_NAME);
try {
$c = new Criteria();
$c->setDistinct();
if ($db instanceof DBPostgres) {
$c->addSelectColumn("substring(" . BookPeer::TITLE . " from position('Potter' in " . BookPeer::TITLE . ")) AS col");
} else {
$this->markTestSkipped();
}
$stmt = BookPeer::doSelectStmt($c);
} catch (PropelException $x) {
$this->fail("Paring of nested functions failed: " . $x->getMessage());
}
}
示例15: testNeedsSelectAliases
public function testNeedsSelectAliases()
{
$c = new Criteria();
$this->assertFalse(BasePeer::needsSelectAliases($c), 'Empty Criterias dont need aliases');
$c = new Criteria();
$c->addSelectColumn(BookPeer::ID);
$c->addSelectColumn(BookPeer::TITLE);
$this->assertFalse(BasePeer::needsSelectAliases($c), 'Criterias with distinct column names dont need aliases');
$c = new Criteria();
BookPeer::addSelectColumns($c);
$this->assertFalse(BasePeer::needsSelectAliases($c), 'Criterias with only the columns of a model dont need aliases');
$c = new Criteria();
$c->addSelectColumn(BookPeer::ID);
$c->addSelectColumn(AuthorPeer::ID);
$this->assertTrue(BasePeer::needsSelectAliases($c), 'Criterias with common column names do need aliases');
}