public function update($condition, $data) { $conds = array(); $dt = array(); foreach ($condition as $key => $val) { if (in_array($key, array("title"))) { $conds[$key] = parent::setValForString($val); } else { $conds[$key] = $val; } } foreach ($data as $key => $val) { if (in_array($key, array("title"))) { $dt[$key] = parent::setValForString($val); } else { $dt[$key] = $val; } } return parent::update($conds, $dt); }
function save($data) { $this->setMode('save'); if (!$this->loadFields()) { return false; } $update_fields_params = array(); foreach ($this->fields as $field) { if ($field['type'] != 'key') { $field = array_merge($field, $this->fields_params); $update_fields_params[] = $field; } } $renderer = new DMRenderer(); $renderer->setFields($update_fields_params); $renderer->setData($data); $renderer->setFieldsPrefix($this->fields_prefix); $mode = $this->getMode(); $aditional_params = array('key_field' => $this->key_field, 'mode' => $mode); $renderer->addParams($aditional_params); $data = $renderer->getFieldsData(); if ($data === false) { $this->errors = $renderer->getErrors(); return false; } $this->key_value = isset($data[$this->key_field]) ? $data[$this->key_field] : 0; if ($this->key_field && $this->key_value) { $this->addWhereCondition(" `{$this->key_field}` = '{$this->key_value}' "); $result = parent::update($data, $this->table); if (!$result) { return $result; } $renderer->triggerEvent('afterSave', $this->key_value, $this->table); if (!empty($this->join_table['name'])) { $this->where_conditions = array(); $join_table_key_field_value = $data[$this->join_table['key_field']]; $this->addWhereCondition(" `{$this->join_table['key_field']}` = '{$join_table_key_field_value}' "); $result = parent::update($data, $this->join_table['name']); $renderer->triggerEvent('afterSave', $this->key_value, $this->table); } } else { $result = parent::insert($data, $this->table); $db = DBMysql::getInstance(); $this->key_value = $db->insertid(); if (!$result) { return $result; } $renderer->triggerEvent('afterSave', $this->key_value, $this->table); if (!empty($this->join_table['name'])) { $this->table_fields[] = array('table' => $this->join_table['name'], 'name' => $this->join_table['join_field']); $data[$this->join_table['join_field']] = $this->key_value; $this->key_field = $this->join_table['key_field']; $result = parent::insert($data, $this->join_table['name']); $join_table_key_field_value = $db->insertid(); $renderer->triggerEvent('afterSave', $join_table_key_field_value, $this->join_table['name']); } } if (!$result) { return $result; } return $result; }
public function update($condition, $data) { $conds = array(); $dt = array(); foreach ($condition as $key => $val) { if (in_array($key, array("name", "lastname", "birthday", "email", "password", "reg_date", "last_update"))) { $conds[$key] = parent::setValForString($val); } else { $conds[$key] = $val; } } foreach ($data as $key => $val) { if (in_array($key, array("name", "lastname", "birthday", "email", "password", "reg_date", "last_update"))) { $dt[$key] = parent::setValForString($val); } else { $dt[$key] = $val; } } return parent::update($conds, $dt); }
public function update($condition, $data) { parent::update($condition, $data); }