private function processSave(AbstractModel $model) { $model->callback('onSaveBegin'); $model_props = $model->toArray(); $table_name = $model->getTableName(); $keys = array(); $values = array(); $primaryKey = $model->getPrimaryKey(); foreach ($model_props as $key => $value) { if ($key !== $primaryKey && $key !== 'childs') { if (is_object($value) || is_array($value)) { continue; } $keys[] = '`' . $key . '`'; if ($value == 'CURRENT_TIMESTAMP' || $value == 'NOW()') { $values[] = "{$value}"; } else { $values[] = "'{$value}'"; } } } $columns = implode(', ', $keys); $vals = implode(', ', $values); $query = "INSERT INTO `{$table_name}`({$columns}) VALUES({$vals})"; $this->dump($query); $result = $this->db->exec($query); if ($result) { $id = $this->db->getLastId(); $model->setId($id); $model->callback('onSaveEnd'); return true; } else { return false; } }