<?php
require_once dirname(__FILE__) . "/bootstrap.php";

//ini_set('error_reporting', E_ALL);
//ini_set('display_errors', 1);

$db = oxDb::getDb();

$result = $db->execute('DELETE FROM oxorderfiles WHERE OXID = \'ABC\'');

$result = $db->startTransaction();

$result = $db->execute('INSERT INTO oxorderfiles (OXID) VALUES (\'ABC\')', array());

$query = 'SELECT OXID FROM oxorderfiles WHERE OXID = \'ABC\'';

// Without params the select will read from the slave DB, if a master-slave licence is present and the entry will not be visible outside the transaction
$result = $db->select($query)->getAll();
echo 'Reading from slave DB before transaction commit' . PHP_EOL;
var_dump($result);

// The entry is only visible when reading explicitly from the master DB
$result = $db->select($query, false, false)->getAll();
echo 'Reading from master DB before transaction commit' . PHP_EOL;
var_dump($result);

$result = $db->commitTransaction();

$result = $db->select($query)->getAll();
echo 'Reading from slave DB after transaction commit' . PHP_EOL;
var_dump($result);
