public function store() { $this->w2PTrimAll(); $msg = $this->check(); if ($msg) { return get_class($this) . '::store-check failed - ' . $msg; } $values = parseFormatSysval($this->sysval_value, $this->sysval_key_id); //lets delete the old values $q = new w2p_Database_Query(); if ($this->sysval_key_id && $this->sysval_title) { $q->setDelete('sysvals'); $q->addWhere('sysval_key_id = ' . (int) $this->sysval_key_id); $q->addWhere('sysval_title = \'' . $this->sysval_title . '\''); if (!$q->exec()) { $q->clear(); return get_class($this) . '::store failed: ' . db_error(); } } foreach ($values as $key => $value) { $q->addTable('sysvals'); $q->addInsert('sysval_key_id', $this->sysval_key_id); $q->addInsert('sysval_title', $this->sysval_title); $q->addInsert('sysval_value_id', $key); $q->addInsert('sysval_value', $value); if (!$q->exec()) { $q->clear(); return get_class($this) . '::store failed: ' . db_error(); } $q->clear(); } return null; }
public function store($unused = null) { $this->w2PTrimAll(); $values = parseFormatSysval($this->sysval_value, $this->sysval_key_id); //lets delete the old values $q = $this->_getQuery(); if ($this->sysval_key_id && $this->sysval_title) { $q->setDelete('sysvals'); $q->addWhere('sysval_key_id = ' . (int) $this->sysval_key_id); $q->addWhere('sysval_title = \'' . $this->sysval_title . '\''); if (!$q->exec()) { $this->_error['store'] = get_class($this) . '::store failed: ' . db_error(); return false; } } $q->clear(); foreach ($values as $key => $value) { $q->addTable('sysvals'); $q->addInsert('sysval_key_id', $this->sysval_key_id); $q->addInsert('sysval_title', $this->sysval_title); $q->addInsert('sysval_value_id', $key); $q->addInsert('sysval_value', $value); if (!$q->exec()) { $this->_error['store'] = get_class($this) . '::store failed: ' . db_error(); return false; } $q->clear(); } return true; }