public function save(Ot_Var_Abstract $var) { $model = new Ot_Model_DbTable_Config(); $thisVar = $model->find($var->getName()); $data = array('varName' => $var->getName(), 'value' => $var->getRawValue()); if (is_null($thisVar)) { $model->insert($data); } else { $model->update($data, null); } }
public function saveAttribute(Ot_Var_Abstract $var, $hostParentId, $attributeId) { $model = new Ot_Model_DbTable_CustomAttributeValue(); $where = $model->getAdapter()->quoteInto('hostParentId = ?', $hostParentId) . ' AND ' . $model->getAdapter()->quoteInto('hostKey = ?', $this->getKey()) . ' AND ' . $model->getAdapter()->quoteInto('attributeId = ?', $attributeId); $thisVar = $model->fetchAll($where); $data = array('hostParentId' => $hostParentId, 'hostKey' => $this->getKey(), 'attributeId' => $attributeId, 'value' => $var->getRawValue()); if ($thisVar->count() == 0) { $model->insert($data); } else { $model->update($data, $where); } }
public function save(Ot_Var_Abstract $var, $accountId) { $model = new Ot_Model_DbTable_AccountAttribute(); $where = $model->getAdapter()->quoteInto('varName = ?', $var->getName()) . ' AND ' . $model->getAdapter()->quoteInto('accountId = ?', $accountId); $thisVar = $model->fetchAll($where); $data = array('accountId' => $accountId, 'varName' => $var->getName(), 'value' => $var->getRawValue()); if ($thisVar->count() == 0) { $model->insert($data); } else { $model->update($data, $where); } }