function update() { $res = $this->mapper->update(); if (is_array($res)) { $res = $this->mapper; } if (is_object($res)) { $res = $this->factory($res); } return is_int($res) ? $this : $res; }
/** * Resolve default filter and assign default value if field not changed */ public function resolveDefaultFilter() { $app = Base::instance(); foreach ($this->map ? $this->map->schema() : [] as $field => $schema) { if ($schema['pkey'] && PDO::PARAM_INT === $schema['pdo_type']) { continue; } $filters = []; $filters['required'] = [!$schema['nullable']]; if (preg_match('/^(?<type>\\w+)(?:\\((?<length>.+)\\))?/', $schema['type'], $match)) { $length = isset($match['length']) ? $match['length'] : null; switch ($match['type']) { case 'int': case 'bigint': case 'smallint': case 'tinyint': case 'integer': $filters['maxInt'] = [null, $length]; break; case 'decimal': case 'double': case 'float': case 'real': $x = $app->split($length); $base = pow(10, $x[0] - $x[1]) - 1; $precision = (pow(10, $x[1]) - 1) * 1 / pow(10, $x[1]); $max = $base + $precision; $filters['maxFloat'] = [$max, $length]; break; case 'enum': case 'set': $filters['choices'] = [$app->split(str_replace(['"', "'"], '', $length)), $schema['nullable']]; break; case 'date': $filters['date'] = [$schema['nullable']]; break; default: $filters['maxLength'] = [$length, $schema['nullable']]; break; } } $this->filters[$field] = $filters; if (!$schema['changed'] && (is_null($schema['value']) || '' === $schema['value']) && !(is_null($schema['default']) || '' === $schema['default'])) { $this->map->set($field, $schema['default']); } } return $this; }
/** Reset cursor @return NULL **/ function reset() { $this->id = NULL; $this->document = array(); parent::reset(); }
/** Reset cursor @return NULL **/ function reset() { foreach ($this->fields as &$field) { $field['value'] = NULL; $field['changed'] = FALSE; if ($field['pkey']) { $field['previous'] = NULL; } unset($field); } foreach ($this->adhoc as &$field) { $field['value'] = NULL; unset($field); } parent::reset(); }
function dbtype() { return $this->mapper->dbtype(); }
/** * Reset cursor * @return NULL **/ function reset() { $this->document = []; parent::reset(); }
/** * Get mapper value * * @param string * @return string */ protected function value($name, $default = null) { return $this->mapper && $this->mapper->exists($name) ? $this->mapper->get($name) : $this->get($name, $default); }