mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-12 16:06:25 +02:00
fix some things
git-svn-id: http://www.observium.org/svn/observer/trunk@2351 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
+20
-4
@@ -51,6 +51,7 @@ function dbQuery($sql, $parameters = array()) {
|
||||
* */
|
||||
function dbInsert($data, $table) {
|
||||
global $fullSql;
|
||||
global $db_stats;
|
||||
// the following block swaps the parameters if they were given in the wrong order.
|
||||
// it allows the method to work for those that would rather it (or expect it to)
|
||||
// follow closer with SQL convention:
|
||||
@@ -64,19 +65,26 @@ function dbInsert($data, $table) {
|
||||
|
||||
$sql = 'INSERT INTO `' . $table . '` (`' . implode('`,`', array_keys($data)) . '`) VALUES (' . implode(',', dbPlaceHolders($data)) . ')';
|
||||
|
||||
$time_start = microtime(true);
|
||||
dbBeginTransaction();
|
||||
$result = dbQuery($sql, $data);
|
||||
if($result) {
|
||||
$id = mysql_insert_id();
|
||||
dbCommitTransaction();
|
||||
return $id;
|
||||
#return $id;
|
||||
} else {
|
||||
if($table != 'Contact') {
|
||||
trigger_error('QDB - Insert failed.', E_USER_WARNING);
|
||||
}
|
||||
dbRollbackTransaction();
|
||||
return false;
|
||||
#$id = false;
|
||||
}
|
||||
$time_end = microtime(true);
|
||||
$db_stats['insert_sec'] += number_format($time_end - $time_start, 8);
|
||||
$db_stats['insert']++;
|
||||
|
||||
return $id;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -85,6 +93,7 @@ function dbInsert($data, $table) {
|
||||
* */
|
||||
function dbUpdate($data, $table, $where = null, $parameters = array()) {
|
||||
global $fullSql;
|
||||
global $db_stats;
|
||||
// the following block swaps the parameters if they were given in the wrong order.
|
||||
// it allows the method to work for those that would rather it (or expect it to)
|
||||
// follow closer with SQL convention:
|
||||
@@ -109,13 +118,20 @@ function dbUpdate($data, $table, $where = null, $parameters = array()) {
|
||||
$data = array_merge($data, $parameters);
|
||||
}
|
||||
|
||||
$time_start = microtime(true);
|
||||
if(dbQuery($sql, $data)) {
|
||||
return mysql_affected_rows();
|
||||
$return = mysql_affected_rows();
|
||||
} else {
|
||||
#echo("$fullSql");
|
||||
trigger_error('QDB - Update failed.', E_USER_WARNING);
|
||||
return false;
|
||||
$return = false;
|
||||
}
|
||||
$time_end = microtime(true);
|
||||
$db_stats['update_sec'] += number_format($time_end - $time_start, 8);
|
||||
$db_stats['update']++;
|
||||
|
||||
return $return;
|
||||
|
||||
}
|
||||
|
||||
function dbDelete($table, $where = null, $parameters = array()) {
|
||||
|
||||
Reference in New Issue
Block a user