// import the Peer class from the package library use Propel\Runtime\Util\PropelModelPager; // create a new instance of the Peer class for a specific table $bookPeer = new BookPeer(); // create a new Book object $book = new Book(); $book->setTitle('The Great Gatsby'); $book->setAuthor('F. Scott Fitzgerald'); // call the doInsert method on the Peer object and pass in the Book object $bookPeer::doInsert($book);
// import the Peer class from the package library use Propel\Runtime\Util\PropelModelPager; // create an array of Book objects $books = array( new Book(array('Title' => 'To Kill a Mockingbird', 'Author' => 'Harper Lee')), new Book(array('Title' => 'Nineteen Eighty-Four', 'Author' => 'George Orwell')), new Book(array('Title' => 'The Catcher in the Rye', 'Author' =>'J.D. Salinger')) ); // call the doInsert method on the BookPeer object with the array of Book objects BookPeer::doInsert($books);In this example, we create an array of Book objects and set the title and author properties for each object. Then we call the doInsert method on the BookPeer object and pass in the array of Book objects to insert them into the database. The BasePeer class and the doInsert method are part of the Propel ORM library for PHP.