PHP code example of stwarog / uow-fuel

1. Go to this page and download the library: Download stwarog/uow-fuel 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/ */

    

stwarog / uow-fuel example snippets

 
FuelEntityManager::forge($db, $config = []);
 
DB::start_transation();
try {
    $todo = Model_Todo::query()->related('lines')->where('id', 1)->get_one();
    $todo->status = 2;
    
    foreach ($todo->lines as $line) {
        $rand = rand(0, 5);
        $line->content = 'changed' . $rand;
    }
    
    $todo->save();
} catch (Exception $e) {
    DB::rollback_transation();
    throw $e;
}
DB::commit_transation();
 
$entityManager = FuelEntityManager::forge($db, $config = []);

$todo = Model_Todo::query()->related('lines')->where('id', 1)->get_one();
$todo->status = 2;

foreach ($todo->lines as $line) {
    $rand = rand(0, 5);
    $line->content = 'changed' . $rand;
}

$entityManager->save($todo);
$entityManager->flush();

# or inline $entityManager->save($todo, $flush = true)