Пример #1
0
 /**
  * Checks if it is allowed to save new, empty objects with a auto increment column
  */
 public function testAllowEmptyWithAutoIncrement()
 {
     $bookreader = new BookReader();
     $bookreader->save();
     $this->assertFalse($bookreader->isNew());
 }
 public static function populateOpinionFavorite($con = null)
 {
     if ($con === null) {
         $con = Propel::getServiceContainer()->getConnection(BookTableMap::DATABASE_NAME);
     }
     $con->beginTransaction();
     $book1 = BookQuery::create()->findOne($con);
     $reader1 = new BookReader();
     $reader1->save($con);
     $bo = new BookOpinion();
     $bo->setBook($book1);
     $bo->setBookReader($reader1);
     $bo->save($con);
     $rf = new ReaderFavorite();
     $rf->setBookOpinion($bo);
     $rf->save($con);
     $con->commit();
 }
Пример #3
0
 /**
  * Testing foreign keys with multiple referrer columns.
  * @link       http://propel.phpdb.org/trac/ticket/606
  */
 public function testMultiColFk()
 {
     $con = Propel::getServiceContainer()->getConnection(BookPeer::DATABASE_NAME);
     ReaderFavoritePeer::doDeleteAll();
     $b1 = new Book();
     $b1->setTitle("Book1");
     $b1->setISBN("ISBN-1");
     $b1->save();
     $r1 = new BookReader();
     $r1->setName("Me");
     $r1->save();
     $bo1 = new BookOpinion();
     $bo1->setBookId($b1->getId());
     $bo1->setReaderId($r1->getId());
     $bo1->setRating(9);
     $bo1->setRecommendToFriend(true);
     $bo1->save();
     $rf1 = new ReaderFavorite();
     $rf1->setReaderId($r1->getId());
     $rf1->setBookId($b1->getId());
     $rf1->save();
     $c = new Criteria(ReaderFavoritePeer::DATABASE_NAME);
     $c->add(ReaderFavoritePeer::BOOK_ID, $b1->getId());
     $c->add(ReaderFavoritePeer::READER_ID, $r1->getId());
     $results = ReaderFavoritePeer::doSelectJoinBookOpinion($c);
     $this->assertEquals(1, count($results), "Expected 1 result");
 }
 /**
  * @see testDoDeleteCompositePK()
  */
 private function createReaderWithId($id)
 {
     $con = Propel::getServiceContainer()->getConnection(BookReaderTableMap::DATABASE_NAME);
     $r = BookReaderQuery::create()->findPk($id);
     if (!$r) {
         $r = new BookReader();
         $r->setName('Reader' . $id)->save();
         $r1Id = $r->getId();
         $sql = "UPDATE " . BookReaderTableMap::TABLE_NAME . " SET id = ? WHERE id = ?";
         $stmt = $con->prepare($sql);
         $stmt->bindValue(1, $id);
         $stmt->bindValue(2, $r1Id);
         $stmt->execute();
     }
 }
Пример #5
0
 public static function populateOpinionFavorite($con = null)
 {
     if ($con === null) {
         $con = Propel::getServiceContainer()->getConnection(BookPeer::DATABASE_NAME);
     }
     $con->beginTransaction();
     $book1 = BookPeer::doSelectOne(new Criteria(), $con);
     $reader1 = new BookReader();
     $reader1->save($con);
     $bo = new BookOpinion();
     $bo->setBook($book1);
     $bo->setBookReader($reader1);
     $bo->save($con);
     $rf = new ReaderFavorite();
     $rf->setBookOpinion($bo);
     $rf->save($con);
     $con->commit();
 }