while (($row = $db->dbResultFetch()) !== false) {
            echo "<tr><td>{$row['id']}</td><td>{$row['name']}</td></tr>";
        }
        echo '</table>';
        die;
    }
}
require_once './lib/common.inc.php';
// ob_start();
echo '<b>start</b><br>';
$db = new dataBase();
$db->simpleQuery("drop table if exists transaction_test;");
$db->simpleQuery("\n        create table transaction_test (\n            id int(10) not null auto_increment,\n            name varchar(50) not null,\n            PRIMARY KEY (id)\n        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
$db2 = new dataBase();
// test transaction isolation
$db2->beginTransaction();
$db2->simpleQuery("insert into transaction_test (name) values('Asia')");
$db2->simpleQuery("insert into transaction_test (name) values('Kasia')");
$db2->simpleQuery("insert into transaction_test (name) values('Natalia')");
check_database_count($db, 0, __LINE__);
// test commit
$db2->commit();
check_database_count($db, 3, __LINE__);
// test no-transaction
$db2->simpleQuery("insert into transaction_test (name) values('Basia')");
check_database_count($db, 4, __LINE__);
// test rollback
$db2->beginTransaction();
$db2->simpleQuery("delete from transaction_test where name = 'Kasia'");
if ($db2->rowCount() !== 1) {
    echo "Expected 1 row to be deleted!<br>";
Beispiel #2
0
 tpl_set_var('acceptList', "");
 tpl_set_var('cacheList', "");
 // wybor wlasciciela - mozna zmieniac tylko swoje skrzynki... chyba, ze jest sie czlonkiem oc team
 if (isset($_GET['cacheid']) && (isUserOwner($usr['userid'], $_GET['cacheid']) && !isset($_GET['abort']) && !isset($_GET['accept']))) {
     tpl_set_var('cachename', getCacheName($_GET['cacheid']));
     tpl_set_var('cacheid', $_GET['cacheid']);
     $tplname = "chowner_chooseuser";
 } else {
     if (isset($_GET['accept']) && $_GET['accept'] == 1) {
         $sql = "SELECT count(id) FROM chowner WHERE cache_id = :1 AND user_id = :2";
         $potwierdzenie = $db->multiVariableQueryValue($sql, 0, $_GET['cacheid'], $usr['userid']);
         if ($potwierdzenie > 0) {
             // zmiana wlasciciela
             tpl_set_var("error_msg", tr('adopt_30'));
             tpl_set_var("info_msg", "");
             $db->beginTransaction();
             require_once $rootpath . 'lib/cache_owners.inc.php';
             $pco = new OrgCacheOwners($db);
             $pco->populateForCache($_GET['cacheid']);
             $oldOwnerId = getCacheOwner($_GET['cacheid']);
             $isCachePublished = isCachePublished($_GET['cacheid']);
             $sql = "DELETE FROM chowner WHERE cache_id = :1 AND user_id = :2";
             $db->multiVariableQuery($sql, $_GET['cacheid'], $usr['userid']);
             if ($isCachePublished) {
                 $sql = "UPDATE caches SET user_id = :2, org_user_id = IF(org_user_id IS NULL, :3, org_user_id) WHERE cache_id= :1";
                 $db->multiVariableQuery($sql, $_GET['cacheid'], $usr['userid'], $oldOwnerId);
             } else {
                 $sql = "UPDATE caches SET user_id = :2 WHERE cache_id= :1";
                 $db->multiVariableQuery($sql, $_GET['cacheid'], $usr['userid']);
             }
             $sql = "UPDATE pictures SET user_id = :2 WHERE object_id = :1";