<?php

require_once 'classes/api/Transaction.php';
require_once 'classes/api/Connection.php';
require_once 'classes/api/Logger.php';
require_once 'classes/api/LoggerTXT.php';
require_once 'classes/api/Record.php';
require_once 'classes/model/Produto.php';
try {
    Transaction::open('estoque');
    Transaction::setLogger(new LoggerTXT('tmp/log_update.txt'));
    Transaction::log('Alterando um produto');
    $p1 = Produto::find(2);
    print $p1->estoque . "<br>\n";
    $p1->estoque += 10;
    print $p1->estoque . "<br>\n";
    $p1->store();
    Transaction::close();
} catch (Exception $e) {
    Transaction::rollback();
    print $e->getMessage();
}
<?php

require_once 'classes/api/Transaction.php';
require_once 'classes/api/Connection.php';
require_once 'classes/api/Logger.php';
require_once 'classes/api/LoggerTXT.php';
require_once 'classes/api/Record.php';
require_once 'classes/model/Produto.php';
try {
    Transaction::open('estoque');
    Transaction::setLogger(new LoggerTXT('tmp/log_protect.txt'));
    Transaction::log('Protegendo o acesso a um produto');
    $p1 = Produto::find(2);
    $p1->estoque = 'dois';
    $p1->store();
    Transaction::close();
} catch (Exception $e) {
    Transaction::rollback();
    print $e->getMessage();
}
<?php

require_once 'classes/api/Transaction.php';
require_once 'classes/api/Connection.php';
require_once 'classes/api/Expression.php';
require_once 'classes/api/Criteria.php';
require_once 'classes/api/Repository.php';
require_once 'classes/api/Record.php';
require_once 'classes/api/Filter.php';
require_once 'classes/api/Logger.php';
require_once 'classes/api/LoggerTXT.php';
require_once 'classes/model/Produto.php';
try {
    Transaction::open('estoque');
    Transaction::setLogger(new LoggerTXT('tmp/log_collection_delete.txt'));
    $criteria = new Criteria();
    $criteria->add(new Filter('descricao', 'like', '%WEBC%'), Expression::OR_OPERATOR);
    $criteria->add(new Filter('descricao', 'like', '%FILMAD%'), Expression::OR_OPERATOR);
    $repository = new Repository('Produto');
    $repository->delete($criteria);
    Transaction::close();
} catch (Exception $e) {
    echo $e->getMessage();
    Transaction::rollback();
}
<?php

require_once 'classes/api/Transaction.php';
require_once 'classes/api/Connection.php';
require_once 'classes/api/Logger.php';
require_once 'classes/api/LoggerTXT.php';
require_once 'classes/api/Record.php';
require_once 'classes/model/Produto.php';
try {
    Transaction::open('estoque');
    Transaction::setLogger(new LoggerTXT('tmp/log_find.txt'));
    Transaction::log('Buscando um produto');
    $p1 = Produto::find(2);
    print $p1->descricao;
    Transaction::close();
} catch (Exception $e) {
    Transaction::rollback();
    print $e->getMessage();
}
<?php

require_once 'classes/api/Transaction.php';
require_once 'classes/api/Connection.php';
require_once 'classes/api/Logger.php';
require_once 'classes/api/LoggerTXT.php';
require_once 'classes/api/Record.php';
require_once 'classes/model/Produto.php';
try {
    Transaction::open('estoque');
    Transaction::setLogger(new LoggerTXT('tmp/log_novo.txt'));
    Transaction::log('Inserindo produto novo');
    $p1 = new Produto();
    $p1->descricao = 'Cerveja artesanal IPA';
    $p1->estoque = 50;
    $p1->preco_custo = 8;
    $p1->preco_venda = 12;
    $p1->codigo_barras = '75363453234234';
    $p1->data_cadastro = date('Y-m-d');
    $p1->origem = 'N';
    $p1->store();
    Transaction::close();
} catch (Exception $e) {
    Transaction::rollback();
    print $e->getMessage();
}
<?php

require_once 'classes/api/Transaction.php';
require_once 'classes/api/Connection.php';
require_once 'classes/api/Logger.php';
require_once 'classes/api/LoggerTXT.php';
require_once 'classes/api/Record.php';
require_once 'classes/model/Produto.php';
try {
    Transaction::open('estoque');
    Transaction::setLogger(new LoggerTXT('tmp/log_clone.txt'));
    Transaction::log('Clonando um produto');
    $p1 = Produto::find(2);
    $p2 = clone $p1;
    $p2->descricao .= ' (clonado)';
    $p2->store();
    Transaction::close();
} catch (Exception $e) {
    Transaction::rollback();
    print $e->getMessage();
}