This commit is contained in:
Stefan Puraner
2016-05-24 15:33:23 +02:00
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);
}