Commit c8d63e095116df2a0e613d9a8c39ea525304c84d
1 parent
b3c2d011
Convert manual queries to autoInsert and whereUpdate.
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@3041 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
12 additions
and
9 deletions
lib/System.inc
| @@ -82,19 +82,22 @@ class System { | @@ -82,19 +82,22 @@ class System { | ||
| 82 | function set($sSettingName, $sSettingValue) { | 82 | function set($sSettingName, $sSettingValue) { |
| 83 | global $default; | 83 | global $default; |
| 84 | if (lookupField($default->system_settings_table, "name", "name", $sSettingName)) { | 84 | if (lookupField($default->system_settings_table, "name", "name", $sSettingName)) { |
| 85 | - // the setting exists, so overwrite it | ||
| 86 | - if ($default->db->query("UPDATE $default->system_settings_table SET value='$sSettingValue' where name='$sSettingName'")) { | ||
| 87 | - return true; | ||
| 88 | - } else { | 85 | + $res = &DBUtil::whereUpdate($default->system_settings_table, |
| 86 | + array('value' => $sSettingValue), array('name' => $sSettingName)); | ||
| 87 | + if (PEAR::isError($res)) { | ||
| 89 | return false; | 88 | return false; |
| 90 | - } | 89 | + } |
| 90 | + return true; | ||
| 91 | } else { | 91 | } else { |
| 92 | - // the setting doesn't exist, lets insert it | ||
| 93 | - if ($default->db->query("INSERT INTO $default->system_settings_table (name, value) VALUES ('$sSettingName', '$sSettingValue')")) { | ||
| 94 | - return true; | ||
| 95 | - } else { | 92 | + $aFieldValues = array( |
| 93 | + 'name' => $sSettingName, | ||
| 94 | + 'value' => $sSettingValue, | ||
| 95 | + ); | ||
| 96 | + $res = DBUtil::autoInsert($default->system_settings_table, $aFieldValues); | ||
| 97 | + if (PEAR::isError($res)) { | ||
| 96 | return false; | 98 | return false; |
| 97 | } | 99 | } |
| 100 | + return true; | ||
| 98 | } | 101 | } |
| 99 | } | 102 | } |
| 100 | } | 103 | } |