Generalize transactions
This commit is contained in:
parent
56b0917acd
commit
7a1133a2fd
|
@ -258,6 +258,10 @@ if (isset($_GET["mssql"])) {
|
|||
return true;
|
||||
}
|
||||
|
||||
function begin() {
|
||||
return queries("BEGIN TRANSACTION");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -485,10 +489,6 @@ WHERE OBJECT_NAME(i.object_id) = " . q($table)
|
|||
;
|
||||
}
|
||||
|
||||
function begin() {
|
||||
return queries("BEGIN TRANSACTION");
|
||||
}
|
||||
|
||||
function last_id() {
|
||||
global $connection;
|
||||
return $connection->result("SELECT SCOPE_IDENTITY()"); // @@IDENTITY can return trigger INSERT
|
||||
|
|
|
@ -837,13 +837,6 @@ if (!defined("DRIVER")) {
|
|||
return array(); // "SQL" not required
|
||||
}
|
||||
|
||||
/** Begin transaction
|
||||
* @return bool
|
||||
*/
|
||||
function begin() {
|
||||
return queries("BEGIN");
|
||||
}
|
||||
|
||||
/** Get last auto increment ID
|
||||
* @return string
|
||||
*/
|
||||
|
|
|
@ -138,6 +138,10 @@ if (isset($_GET["oracle"])) {
|
|||
|
||||
//! support empty $set in insert()
|
||||
|
||||
function begin() {
|
||||
return true; // automatic start
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -328,10 +332,6 @@ ORDER BY uc.constraint_type, uic.column_position", $connection2) as $row) {
|
|||
return apply_queries("DROP TABLE", $tables);
|
||||
}
|
||||
|
||||
function begin() {
|
||||
return true; // automatic start
|
||||
}
|
||||
|
||||
function last_id() {
|
||||
return 0; //!
|
||||
}
|
||||
|
|
|
@ -539,10 +539,6 @@ ORDER BY p.proname');
|
|||
return get_vals("SELECT langname FROM pg_catalog.pg_language");
|
||||
}
|
||||
|
||||
function begin() {
|
||||
return queries("BEGIN");
|
||||
}
|
||||
|
||||
function last_id() {
|
||||
return 0; // there can be several sequences
|
||||
}
|
||||
|
|
|
@ -210,6 +210,18 @@ if (isset($_GET["simpledb"])) {
|
|||
return true;
|
||||
}
|
||||
|
||||
function begin() {
|
||||
return false;
|
||||
}
|
||||
|
||||
function commit() {
|
||||
return false;
|
||||
}
|
||||
|
||||
function rollback() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -60,4 +60,19 @@
|
|||
return false;
|
||||
}
|
||||
|
||||
/** Begin transaction
|
||||
* @return bool
|
||||
*/
|
||||
function begin() {
|
||||
return queries("BEGIN");
|
||||
}
|
||||
|
||||
function commit() {
|
||||
return queries("COMMIT");
|
||||
}
|
||||
|
||||
function rollback() {
|
||||
return queries("ROLLBACK");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -173,7 +173,7 @@ if ($_POST && !$error) {
|
|||
$cols = array_keys($fields);
|
||||
preg_match_all('~(?>"[^"]*"|[^"\\r\\n]+)+~', $file, $matches);
|
||||
$affected = count($matches[0]);
|
||||
begin();
|
||||
$driver->begin();
|
||||
$separator = ($_POST["separator"] == "csv" ? "," : ($_POST["separator"] == "tsv" ? "\t" : ";"));
|
||||
$rows = array();
|
||||
foreach ($matches[0] as $key => $val) {
|
||||
|
@ -192,10 +192,10 @@ if ($_POST && !$error) {
|
|||
}
|
||||
$result = (!$rows || $driver->insertUpdate($TABLE, $rows, $primary));
|
||||
if ($result) {
|
||||
queries("COMMIT");
|
||||
$driver->commit();
|
||||
}
|
||||
queries_redirect(remove_from_uri("page"), lang('%d row(s) have been imported.', $affected), $result);
|
||||
queries("ROLLBACK"); // after queries_redirect() to not overwrite error
|
||||
$driver->rollback(); // after queries_redirect() to not overwrite error
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue