Example #1
0
 function update($model)
 {
     $fields = $model->dao->table_fields;
     $id_column = $model->dao->id_column;
     $query = "UPDATE {$this->table} SET ";
     $params = array();
     $comma = '';
     foreach ($fields as $field) {
         $query .= "{$comma}{$field}=:{$field}";
         $comma = ',';
         $params[$field] = $model->{$field};
     }
     $query .= " WHERE {$this->table}.{$this->id_column} = :id";
     $params['id'] = $model->{$id_column};
     $pdo_statement = $this::getConnection()->pdo->prepare($query);
     $response = new Response();
     try {
         $result = $pdo_statement->execute($params);
         $response->setStatus(true);
         $response->addMessage('successes', 'update', $model->update_success_message);
     } catch (\PDOException $e) {
         $response->addMessage('errors', 'update', array($e->getMessage(), $model->update_failure_message));
     }
     return $response;
 }
Example #2
0
 function update()
 {
     $messages = $this->getValidationMessages();
     if (count($messages) > 0) {
         $response = new Response();
         $i = 0;
         foreach ($messages as $k => $v) {
             $response->addMessage('errors', $k, $v);
         }
         return $response;
     }
     return $this->dao->update($this);
 }