- Remove parameters "new" after checked it in method postPrestudentstatus of controller Prestudentstatus

- Method insert of DB_Model doesn't use anymore insert_id() from CI because it forces to have a sequence
  and doesn't return the primary key when it's composed by more columns
This commit is contained in:
paolo
2016-05-24 15:04:35 +02:00
parent 4f8826dc3f
commit e76e1af15c
2 changed files with 18 additions and 1 deletions
@@ -61,6 +61,9 @@ class Prestudentstatus extends APIv1_Controller
{
if(isset($prestudentstatus['new']) && $prestudentstatus['new'] == true)
{
// Remove new parameter to avoid DB insert errors
unset($prestudentstatus['new']);
$result = $this->PrestudentstatusModel->insert($prestudentstatus);
}
else
+15 -1
View File
@@ -33,7 +33,21 @@ class DB_Model extends FHC_Model
// DB-INSERT
if ($this->db->insert($this->dbTable, $data))
return $this->_success($this->db->insert_id());
{
// Avoid to use method insert_id() from CI because it forces to have a sequence
// and doesn't return the primary key when it's composed by more columns
$primaryKeysArray = array();
foreach ($this->pk as $key => $value)
{
if(isset($data[$value]))
{
$primaryKeysArray[$value] = $data[$value];
}
}
return $this->_success($primaryKeysArray);
}
else
return $this->_error($this->db->error(), FHC_DB_ERROR);
}