PHP code example of wakers / nette-propel2

1. Go to this page and download the library: Download wakers/nette-propel2 library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

wakers / nette-propel2 example snippets


$con = Propel\Runtime\Propel::getConnection();

$con->beginTransaction();

try
{
    $book = new Wakers\Module\MyModule\Book;
    $book->setName('Any book name');
    $book->save();
    
    // Do something else
    
    $con->commit();
}
catch (Propel\Runtime\Exception\PropelException $exception)
{
    $con->rollBack();
}


$books = Wakers\Module\MyModule\BookQuery::create()->find();

foreach ($books as $book)
{
    bdump($book->getName());
}