public function update() { global $db; $sql = "UPDATE ".TB_PREFIX."system_defaults SET value = :value WHERE name = :name"; //dont worry about checking db if were using the core extension if ( $this->extension_name != "core" ) { $SI_EXTENSIONS = new SimpleInvoices_Db_Table_Extensions(); $extension_id = $SI_EXTENSIONS->findByName($extension_name); } else { $extension_id = 0; } if ($extension_id >= 0) { $sql .= " AND extension_id = :extension_id"; } else { die(htmlsafe("Invalid extension name: ".$extension)); } if ($db->query($sql, ':value', $this->value, ':name', $this->name, ':extension_id', $extension_id)) { return true; } return false; }
/** * Replaces updateDefault * * @param mixed $data * @param mixed $id * @return int */ public function update($name, $value, $extension_name = "core") { $auth_session = Zend_Registry::get('auth_session'); $where = array(); $where[] = $this->getAdapter()->quoteInto('name = ?', $name); $SI_EXTENSIONS = new SimpleInvoices_Db_Table_Extensions(); $extension_id = $SI_EXTENSIONS->findByName($extension_name); if ($extension_id >= 0) { $where[] = $this->getAdapter()->quoteInto('extension_id = ?', $extension_id); } else { throw new Exception("Invalid extension name: " . str_replace(array('{', '}', '+'), array('{', '}', '+'), htmlentities($extension_name, ENT_QUOTES, 'UTF-8'))); exit(1); } return parent::update(array('value' => $value), $where); }