当前位置: 首页>>代码示例>>PHP>>正文


PHP BookTableMap::doDelete方法代码示例

本文整理汇总了PHP中propel\tests\bookstore\map\BookTableMap::doDelete方法的典型用法代码示例。如果您正苦于以下问题:PHP BookTableMap::doDelete方法的具体用法?PHP BookTableMap::doDelete怎么用?PHP BookTableMap::doDelete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在propel\tests\bookstore\map\BookTableMap的用法示例。


在下文中一共展示了BookTableMap::doDelete方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testScenarioUsingQuery


//.........这里部分代码省略.........
     $this->assertEquals(file_get_contents($clob_path), (string) $m1_lookup->getExcerpt(), 'CLOB was correctly updated');
     // now update the BLOB column and save it & check the results
     $m1_lookup->setCoverImage(file_get_contents($blob2_path));
     $m1_lookup->save();
     $m2_lookup = MediaQuery::create()->findPk($m1_id);
     $this->assertNotNull($m2_lookup, 'Can find just-created media item');
     $this->assertEquals(md5(file_get_contents($blob2_path)), md5(stream_get_contents($m2_lookup->getCoverImage())), 'BLOB was correctly overwritten');
     // Testing count() functionality
     // -------------------------------
     $records = BookQuery::create()->find();
     $count = BookQuery::create()->count();
     $this->assertEquals($count, count($records), 'correct number of results');
     // Test many-to-many relationships
     // ---------------
     // init book club list 1 with 2 books
     $blc1 = new BookClubList();
     $blc1->setGroupLeader("Crazyleggs");
     $blc1->setTheme("Happiness");
     $brel1 = new BookListRel();
     $brel1->setBook($phoenix);
     $brel2 = new BookListRel();
     $brel2->setBook($dj);
     $blc1->addBookListRel($brel1);
     $blc1->addBookListRel($brel2);
     $blc1->save();
     $this->assertNotNull($blc1->getId(), 'BookClubList 1 was saved');
     // init book club list 2 with 1 book
     $blc2 = new BookClubList();
     $blc2->setGroupLeader("John Foo");
     $blc2->setTheme("Default");
     $brel3 = new BookListRel();
     $brel3->setBook($phoenix);
     $blc2->addBookListRel($brel3);
     $blc2->save();
     $this->assertNotNull($blc2->getId(), 'BookClubList 2 was saved');
     // re-fetch books and lists from db to be sure that nothing is cached
     $crit = new Criteria();
     $crit->add(BookTableMap::COL_ID, $phoenix->getId());
     $phoenix = BookQuery::create(null, $crit)->findOne();
     $this->assertNotNull($phoenix, "book 'phoenix' has been re-fetched from db");
     $crit = new Criteria();
     $crit->add(BookClubListTableMap::COL_ID, $blc1->getId());
     $blc1 = BookClubListQuery::create(null, $crit)->findOne();
     $this->assertNotNull($blc1, 'BookClubList 1 has been re-fetched from db');
     $crit = new Criteria();
     $crit->add(BookClubListTableMap::COL_ID, $blc2->getId());
     $blc2 = BookClubListQuery::create(null, $crit)->findOne();
     $this->assertNotNull($blc2, 'BookClubList 2 has been re-fetched from db');
     $relCount = $phoenix->countBookListRels();
     $this->assertEquals(2, $relCount, "book 'phoenix' has 2 BookListRels");
     $relCount = $blc1->countBookListRels();
     $this->assertEquals(2, $relCount, 'BookClubList 1 has 2 BookListRels');
     $relCount = $blc2->countBookListRels();
     $this->assertEquals(1, $relCount, 'BookClubList 2 has 1 BookListRel');
     // Cleanup (tests DELETE)
     // ----------------------
     // Removing books that were just created
     // First finding book by PK (=$phoenix_id) ....
     $hp = BookQuery::create()->findPk($phoenix_id);
     $this->assertNotNull($hp, 'Could find just-created book');
     // Attempting to delete [multi-table] by found pk
     $c = new Criteria();
     $c->add(BookTableMap::COL_ID, $hp->getId());
     // The only way for cascading to work currently
     // is to specify the author_id and publisher_id (i.e. the fkeys
     // have to be in the criteria).
     $c->add(AuthorTableMap::COL_ID, $hp->getAuthor()->getId());
     $c->add(PublisherTableMap::COL_ID, $hp->getPublisher()->getId());
     $c->setSingleRecord(true);
     BookTableMap::doDelete($c);
     // Checking to make sure correct records were removed.
     $this->assertEquals(3, AuthorQuery::create()->count(), 'Correct records were removed from author table');
     $this->assertEquals(3, PublisherQuery::create()->count(), 'Correct records were removed from publisher table');
     $this->assertEquals(3, BookQuery::create()->count(), 'Correct records were removed from book table');
     // Attempting to delete books by complex criteria
     BookQuery::create()->filterByISBN("043935806X")->_or()->where('Book.ISBN = ?', "0380977427")->_or()->where('Book.ISBN = ?', "0140422161")->delete();
     // Attempting to delete book [id = $td_id]
     $td->delete();
     // Attempting to delete authors
     AuthorQuery::create()->filterById($stephenson_id)->delete();
     AuthorQuery::create()->filterById($byron_id)->delete();
     $grass->delete();
     // Attempting to delete publishers
     PublisherQuery::create()->filterById($morrow_id)->delete();
     PublisherQuery::create()->filterById($penguin_id)->delete();
     $vintage->delete();
     // These have to be deleted manually also since we have onDelete
     // set to SETNULL in the foreign keys in book. Is this correct?
     $rowling->delete();
     $scholastic->delete();
     $blc1->delete();
     $blc2->delete();
     $this->assertCount(0, AuthorQuery::create()->find(), 'no records in [author] table');
     $this->assertCount(0, PublisherQuery::create()->find(), 'no records in [publisher] table');
     $this->assertCount(0, BookQuery::create()->find(), 'no records in [book] table');
     $this->assertCount(0, ReviewQuery::create()->find(), 'no records in [review] table');
     $this->assertCount(0, MediaQuery::create()->find(), 'no records in [media] table');
     $this->assertCount(0, BookClubListQuery::create()->find(), 'no records in [book_club_list] table');
     $this->assertCount(0, BookListRelQuery::create()->find(), 'no records in [book_x_list] table');
 }
开发者ID:naldz,项目名称:cyberden,代码行数:101,代码来源:BookstoreTest.php

示例2: testDoDelete_ByObj

 /**
  * Test deleting a row by passing the generated object to doDelete().
  */
 public function testDoDelete_ByObj()
 {
     // 1) get an arbitrary book
     $book = BookQuery::create()->findOne();
     $bookId = $book->getId();
     // 2) now delete that book
     BookTableMap::doDelete($book);
     // 3) now make sure it's gone
     $obj = BookQuery::create()->findPk($bookId);
     $this->assertNull($obj, "Expect NULL when retrieving on no matching Book.");
 }
开发者ID:kalaspuffar,项目名称:php-orm-benchmark,代码行数:14,代码来源:GeneratedQueryDoDeleteTest.php


注:本文中的propel\tests\bookstore\map\BookTableMap::doDelete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。