}
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>";
    die;
}
check_database_count($db, 4, __LINE__);
check_database_count($db2, 3, __LINE__);
$db2->rollback();
check_database_count($db2, 4, __LINE__);
예제 #2
0
         //    $params['user_id']['value'] = $user_id;
         //    $params['user_id']['data_type'] = 'string';
         //    $db->paramQuery($sql, $params);
         //}
         // put log into cache logs.
         if ($isCachePublished) {
             $logMessage = tr('adopt_32');
             $oldUserName = '******' . $absolute_server_URI . 'viewprofile.php?userid=' . $oldOwnerId . '">' . getUsername($oldOwnerId) . '</a> ';
             $newUserName = '******' . $absolute_server_URI . 'viewprofile.php?userid=' . $usr['userid'] . '">' . getUsername($usr['userid']) . '</a>';
             $logMessage = str_replace('{oldUserName}', $oldUserName, $logMessage);
             $logMessage = str_replace('{newUserName}', $newUserName, $logMessage);
             $sql = 'INSERT INTO cache_logs(cache_id, user_id, type, date, text, text_html, text_htmledit, date_created, last_modified, uuid, node)
                         VALUES                (:1,       -1,      3,    NOW(), :2,  1,         1,             NOW(),        NOW(),         :3,   :4)';
             $db->multiVariableQuery($sql, $_GET['cacheid'], $logMessage, create_uuid(), $oc_nodeid);
         }
         $db->commit();
         $message = tr('adopt_15');
         $message = str_replace('{cacheName}', getCacheName($_GET['cacheid']), $message);
         tpl_set_var('error_msg', $message . '<br /><br />');
         tpl_set_var("error_msg", "");
         $mailContent = tr('adopt_31');
         $mailContent = str_replace('\\n', "\n", $mailContent);
         $mailContent = str_replace('{userName}', $usr['username'], $mailContent);
         $mailContent = str_replace('{cacheName}', getCacheName($_GET['cacheid']), $mailContent);
         mb_send_mail_2(getUserEmail($oldOwnerId), tr('adopt_18'), $mailContent, emailHeaders());
     }
 }
 if (isset($_GET['accept']) && $_GET['accept'] == 0) {
     // odrzucenie zmiany
     $sql = "DELETE FROM chowner WHERE cache_id = :1 AND user_id = :2";
     $db->multiVariableQuery($sql, $_GET['cacheid'], $usr['userid']);