public static function depopulate() { AcctAccessRolePeer::doDeleteAll(); AuthorPeer::doDeleteAll(); BookstorePeer::doDeleteAll(); BookstoreContestPeer::doDeleteAll(); BookstoreContestEntryPeer::doDeleteAll(); BookstoreEmployeePeer::doDeleteAll(); BookstoreEmployeeAccountPeer::doDeleteAll(); BookstoreSalePeer::doDeleteAll(); BookClubListPeer::doDeleteAll(); BookOpinionPeer::doDeleteAll(); BookReaderPeer::doDeleteAll(); BookListRelPeer::doDeleteAll(); BookPeer::doDeleteAll(); ContestPeer::doDeleteAll(); CustomerPeer::doDeleteAll(); MediaPeer::doDeleteAll(); PublisherPeer::doDeleteAll(); ReaderFavoritePeer::doDeleteAll(); ReviewPeer::doDeleteAll(); }
/** * Testing foreign keys with multiple referrer columns. * @link http://propel.phpdb.org/trac/ticket/606 */ public function testMultiColJoin() { BookstoreContestPeer::doDeleteAll(); BookstoreContestEntryPeer::doDeleteAll(); $bs = new Bookstore(); $bs->setStoreName("Test1"); $bs->setPopulationServed(5); $bs->save(); $bs1Id = $bs->getId(); $bs2 = new Bookstore(); $bs2->setStoreName("Test2"); $bs2->setPopulationServed(5); $bs2->save(); $bs2Id = $bs2->getId(); $ct1 = new Contest(); $ct1->setName("Contest1!"); $ct1->save(); $ct1Id = $ct1->getId(); $ct2 = new Contest(); $ct2->setName("Contest2!"); $ct2->save(); $ct2Id = $ct2->getId(); $cmr = new Customer(); $cmr->setName("Customer1"); $cmr->save(); $cmr1Id = $cmr->getId(); $cmr2 = new Customer(); $cmr2->setName("Customer2"); $cmr2->save(); $cmr2Id = $cmr2->getId(); $contest = new BookstoreContest(); $contest->setBookstoreId($bs1Id); $contest->setContestId($ct1Id); $contest->save(); $contest = new BookstoreContest(); $contest->setBookstoreId($bs2Id); $contest->setContestId($ct1Id); $contest->save(); $entry = new BookstoreContestEntry(); $entry->setBookstoreId($bs1Id); $entry->setContestId($ct1Id); $entry->setCustomerId($cmr1Id); $entry->save(); $entry = new BookstoreContestEntry(); $entry->setBookstoreId($bs1Id); $entry->setContestId($ct1Id); $entry->setCustomerId($cmr2Id); $entry->save(); // Note: this test isn't really working very well. We setup fkeys that // require that the BookstoreContest rows exist and then try to violate // the rules ... :-/ This may work in some lenient databases, but an error // is expected here. /* * Commented out for now ... though without it, this test may not really be testing anything $entry = new BookstoreContestEntry(); $entry->setBookstoreId($bs1Id); $entry->setContestId($ct2Id); $entry->setCustomerId($cmr2Id); $entry->save(); */ $c = new Criteria(); $c->addJoin(array(BookstoreContestEntryPeer::BOOKSTORE_ID, BookstoreContestEntryPeer::CONTEST_ID), array(BookstoreContestPeer::BOOKSTORE_ID, BookstoreContestPeer::CONTEST_ID)); $results = BookstoreContestEntryPeer::doSelect($c); $this->assertEquals(2, count($results)); foreach ($results as $result) { $this->assertEquals($bs1Id, $result->getBookstoreId()); $this->assertEquals($ct1Id, $result->getContestId()); } }
public static function depopulate($con = null) { if ($con === null) { $con = Propel::getConnection(BookPeer::DATABASE_NAME); } $con->beginTransaction(); AuthorPeer::doDeleteAll($con); BookstorePeer::doDeleteAll($con); BookstoreContestPeer::doDeleteAll($con); BookstoreContestEntryPeer::doDeleteAll($con); BookstoreEmployeePeer::doDeleteAll($con); BookstoreEmployeeAccountPeer::doDeleteAll($con); BookstoreSalePeer::doDeleteAll($con); BookClubListPeer::doDeleteAll($con); BookOpinionPeer::doDeleteAll($con); BookReaderPeer::doDeleteAll($con); BookListRelPeer::doDeleteAll($con); BookPeer::doDeleteAll($con); ContestPeer::doDeleteAll($con); CustomerPeer::doDeleteAll($con); MediaPeer::doDeleteAll($con); PublisherPeer::doDeleteAll($con); ReaderFavoritePeer::doDeleteAll($con); ReviewPeer::doDeleteAll($con); $con->commit(); }