public function saveProxySettings($proxy_settings) { $db = $this->client->getDB(); $proxy_fields = array('proxy_status', 'proxy_host', 'proxy_port'); foreach ($proxy_fields as $field) { if (isset($proxy_settings[$field])) { $query = "SELECT keyword FROM settings WHERE module = %s AND keyword = %s"; $res = $db->queryF($query, array('text', 'text'), array('common', $field)); $row = array(); while ($row = $db->fetchAssoc($res)) { break; } if (count($row) > 0) { $db->update('settings', array('value' => array('text', $proxy_settings[$field])), array('module' => array('text', 'common'), 'keyword' => array('text', $field))); } else { $db->insert('settings', array('module' => array('text', 'common'), 'keyword' => array('text', $field), 'value' => array('text', $proxy_settings[$field]))); } } } }