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


PHP BookTableMap::doDeleteAll方法代碼示例

本文整理匯總了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']));
 }
開發者ID:badelas,項目名稱:thelia,代碼行數:34,代碼來源:ArrayFormatterWithTest.php

示例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);
 }
開發者ID:disider,項目名稱:Propel2,代碼行數:48,代碼來源:PropelPDOTest.php

示例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.");
 }
開發者ID:kalaspuffar,項目名稱:php-orm-benchmark,代碼行數:9,代碼來源:GeneratedQueryDoDeleteTest.php


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