2011-03-01 Miguel de Dios <miguel.dedios@artica.es>
* include/db/postgresql.php, include/db/mysql.php, include/functions_db.php: separate the function "get_db_all_row_by_steps_sql", "process_sql_begin", "process_sql_commit" and "process_sql_rollback" into the two version for MySQL and PostgreSQL engine. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4040 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
830742c25d
commit
57b3aea57d
|
@ -1,3 +1,10 @@
|
|||
2011-03-01 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* include/db/postgresql.php, include/db/mysql.php, include/functions_db.php:
|
||||
separate the function "get_db_all_row_by_steps_sql", "process_sql_begin",
|
||||
"process_sql_commit" and "process_sql_rollback" into the two version for
|
||||
MySQL and PostgreSQL engine.
|
||||
|
||||
2011-03-01 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
|
||||
|
||||
* include/ajax/skins.ajax.php: Replaced "give_acl" function call to
|
||||
|
|
|
@ -895,4 +895,37 @@ function mysql_process_sql_delete($table, $where, $where_join = 'AND') {
|
|||
|
||||
return process_sql ($query);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get row by row the DB by SQL query. The first time pass the SQL query and
|
||||
* rest of times pass none for iterate in table and extract row by row, and
|
||||
* the end return false.
|
||||
*
|
||||
* @param bool $new Default true, if true start to query.
|
||||
* @param resource $result The resource of mysql for access to query.
|
||||
* @param string $sql
|
||||
* @return mixed The row or false in error.
|
||||
*/
|
||||
function mysql_get_db_all_row_by_steps_sql($new = true, &$result, $sql = null) {
|
||||
if ($new == true)
|
||||
$result = mysql_query($sql);
|
||||
|
||||
return mysql_fetch_assoc($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts a database transaction.
|
||||
*/
|
||||
function mysql_process_sql_begin() {
|
||||
mysql_query ('SET AUTOCOMMIT = 0');
|
||||
mysql_query ('START TRANSACTION');
|
||||
}
|
||||
|
||||
/**
|
||||
* Commits a database transaction.
|
||||
*/
|
||||
function mysql_process_sql_commit() {
|
||||
mysql_query ('COMMIT');
|
||||
mysql_query ('SET AUTOCOMMIT = 0');
|
||||
}
|
||||
?>
|
|
@ -914,4 +914,35 @@ function postgresql_process_sql_delete($table, $where, $where_join = 'AND') {
|
|||
|
||||
return process_sql ($query);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get row by row the DB by SQL query. The first time pass the SQL query and
|
||||
* rest of times pass none for iterate in table and extract row by row, and
|
||||
* the end return false.
|
||||
*
|
||||
* @param bool $new Default true, if true start to query.
|
||||
* @param resource $result The resource of mysql for access to query.
|
||||
* @param string $sql
|
||||
* @return mixed The row or false in error.
|
||||
*/
|
||||
function postgresql_get_db_all_row_by_steps_sql($new = true, &$result, $sql = null) {
|
||||
if ($new == true)
|
||||
$result = pg_query($sql);
|
||||
|
||||
return pg_fetch_assoc($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts a database transaction.
|
||||
*/
|
||||
function postgresql_process_sql_begin() {
|
||||
pg_query('BEGIN TRANSACTION');
|
||||
}
|
||||
|
||||
/**
|
||||
* Commits a database transaction.
|
||||
*/
|
||||
function postgresql_process_sql_commit() {
|
||||
pg_query('COMMIT');
|
||||
}
|
||||
?>
|
|
@ -2301,10 +2301,16 @@ function get_db_all_rows_filter($table, $filter = array(), $fields = false, $whe
|
|||
* @return mixed The row or false in error.
|
||||
*/
|
||||
function get_db_all_row_by_steps_sql($new = true, &$result, $sql = null) {
|
||||
if ($new == true)
|
||||
$result = mysql_query($sql);
|
||||
global $config;
|
||||
|
||||
return mysql_fetch_assoc($result);
|
||||
switch ($config["dbtype"]) {
|
||||
case "mysql":
|
||||
return mysql_get_db_all_row_by_steps_sql($new, $result, $sql);
|
||||
break;
|
||||
case "postgresql":
|
||||
return postgresql_get_db_all_row_by_steps_sql($new, $result, $sql);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3323,17 +3329,33 @@ function process_sql_delete($table, $where, $where_join = 'AND') {
|
|||
/**
|
||||
* Starts a database transaction.
|
||||
*/
|
||||
function process_sql_begin () {
|
||||
mysql_query ('SET AUTOCOMMIT = 0');
|
||||
mysql_query ('START TRANSACTION');
|
||||
function process_sql_begin() {
|
||||
global $config;
|
||||
|
||||
switch ($config["dbtype"]) {
|
||||
case "mysql":
|
||||
return mysql_process_sql_begin();
|
||||
break;
|
||||
case "postgresql":
|
||||
return postgresql_process_sql_begin();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Commits a database transaction.
|
||||
*/
|
||||
function process_sql_commit () {
|
||||
mysql_query ('COMMIT');
|
||||
mysql_query ('SET AUTOCOMMIT = 0');
|
||||
function process_sql_commit() {
|
||||
global $config;
|
||||
|
||||
switch ($config["dbtype"]) {
|
||||
case "mysql":
|
||||
return mysql_process_sql_commit();
|
||||
break;
|
||||
case "postgresql":
|
||||
return postgresql_process_sql_commit();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue