Exemplo n.º 1
0
 /**
  * @param       $id
  * @param array $data
  *
  * @return int
  */
 public function update($id, array $data)
 {
     $old_db = new OldDatabase();
     return $old_db->updateData('authors', array('id' => $id), $data);
 }
Exemplo n.º 2
0
 /**
  * @param       $id
  * @param array $data
  *
  * @return int
  */
 public function update($id, array $data)
 {
     /* Fetches the type */
     if (isset($data['type'])) {
         $repo = new TypeRepository($this->db);
         $type = $repo->where('name', '=', $data['type'])->findSingle();
         $data['type_id'] = $type->getId();
         unset($data['type']);
     }
     /* Fetches the study field */
     if (isset($data['study_field'])) {
         $repo = new StudyFieldRepository($this->db);
         $type = $repo->where('name', '=', $data['study_field'])->findSingle();
         $data['study_field_id'] = $type->getId();
         unset($data['study_field']);
     }
     /* If checkbox is unchecked, we do not get a value */
     if (!isset($data['foreign'])) {
         $data['foreign'] = 0;
     }
     $old_db = new OldDatabase();
     return $old_db->updateData('publications', array('id' => $id), $data);
 }