Fix id of newly created trials

This commit is contained in:
Karsten Heiken
2011-08-03 11:03:20 +02:00
parent f5e3202e88
commit e28f341a78

View File

@@ -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;
} }
/** /**