开发者

codeigniter mysql query problem

I execute a simple insert query, however this insert is done multiple times sometimes unexpectedly. The code for insert is :

$query=$this->db->query("INSERT INTO clientaccesshistory (jobid, clientid,firstname,lastname,clientname,menu,submenu,starttime) VALUES ('$time','$userID','$firstname','$lastname','$clientname','Monitor/Verify', '$this->job_name',current_timestamp() )");

When i look in the database though this information is sometimes there 3 times, sometimes its just once like it is supposed to be. I think this is some issue with connecting to mysql, and then retries till it inser开发者_如何学Pythonts three times?

I tested the front end to see if the function is actually be called more than once by putting an alert there, but no problem there whatsoever.


Your code almost certainly has to be in a variable loop of some kind. This code, like wonk says, will not add more than one record, ever.


This won't be of much help, but you can try using this-

$arr = array(
jobid => $time,
clientid => $userID,
firstname => $firstname,
lastname => $lastname,
clientname => $clientname,
menu => 'Monitor/Verify',
submenu => $this->job_name,
starttime => current_timestamp()
);

$this->db->insert('clientaccesshistory', $arr);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜