diff --git a/application/models/trial.php b/application/models/trial.php index c18769c..df3729d 100644 --- a/application/models/trial.php +++ b/application/models/trial.php @@ -36,7 +36,15 @@ class Trial extends CI_Model { * @return bool was the insert successful */ 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; } /**