本文整理汇总了PHP中propel\tests\bookstore\map\BookTableMap::doDeleteAll方法的典型用法代码示例。如果您正苦于以下问题:PHP BookTableMap::doDeleteAll方法的具体用法?PHP BookTableMap::doDeleteAll怎么用?PHP BookTableMap::doDeleteAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类propel\tests\bookstore\map\BookTableMap
的用法示例。
在下文中一共展示了BookTableMap::doDeleteAll方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testFindOneWithSameRelatedObject
/**
* @see http://www.propelorm.org/ticket/959
*/
public function testFindOneWithSameRelatedObject()
{
BookTableMap::doDeleteAll();
AuthorTableMap::doDeleteAll();
$auth = new Author();
$auth->setFirstName('John');
$auth->setLastName('Doe');
$auth->save();
$book1 = new Book();
$book1->setTitle('Hello');
$book1->setISBN('FA404');
$book1->setAuthor($auth);
$book1->save();
$book2 = new Book();
$book2->setTitle('World');
$book2->setISBN('FA404');
$book2->setAuthor($auth);
$book2->save();
BookTableMap::clearInstancePool();
AuthorTableMap::clearInstancePool();
$c = new ModelCriteria('bookstore', '\\Propel\\Tests\\Bookstore\\Book');
$c->setFormatter(ModelCriteria::FORMAT_ARRAY);
$c->join('Propel\\Tests\\Bookstore\\Book.Author');
$c->with('Author');
$books = $c->find();
$this->assertEquals(2, count($books));
$firstBook = $books[0];
$this->assertTrue(isset($firstBook['Author']));
$secondBook = $books[1];
$this->assertTrue(isset($secondBook['Author']));
}
示例2: 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);
}
示例3: testDoDeleteAll_Cascade
/**
* Test the doDeleteAll() method when onDelete="CASCADE".
*/
public function testDoDeleteAll_Cascade()
{
BookTableMap::doDeleteAll();
$this->assertCount(0, MediaQuery::create()->find(), "Expect all media rows to have been cascade deleted.");
$this->assertCount(0, ReviewQuery::create()->find(), "Expect all review rows to have been cascade deleted.");
}