Fix id of newly created trials
This commit is contained in:
@@ -36,7 +36,15 @@ class Trial extends CI_Model {
|
|||||||
* @return bool was the insert successful
|
* @return bool was the insert successful
|
||||||
*/
|
*/
|
||||||
public function create($data) {
|
public function create($data) {
|
||||||
return $this->db->insert('trials', $data);
|
do {
|
||||||
|
$data['id'] = random_hash();
|
||||||
|
} while ($this->db->where('id', $data['id'])->from('trials')->count_all_results() > 0);
|
||||||
|
|
||||||
|
|
||||||
|
if ($this->db->insert('trials', $data))
|
||||||
|
return $data['id'];
|
||||||
|
else
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user