Welcome Guest, Not a member yet? Register   Sign In
Triple database inserts (with Safari)
#1

[eluser]ministry[/eluser]
Hi,
I wrote a controller function that simply inserts an entry in my database, then loads a view.

eg.
Code:
$data['name']="Mike";
$data['age']="30";
$data['city']="Rome";
$this->db->insert('users', $data);
$this->load->view('indexfile');

It works fine on Firefox (I get a single database entry).
If I run it on Safari (ver. 4.0.4 on Mac) I get the same entries three time!
If I comment the last line (so I stop the script without loading the view) I get a single entry! It seems that refreshing the page (no matter what view file I load) repeats the query again and again.
But according to the Profiler the query is executed only once!

What the hell...? :-)
It's a Safari issue?
#2

[eluser]danmontgomery[/eluser]
PHP is executed server side, before it ever gets to the browser, so that's unlikely.
#3

[eluser]ministry[/eluser]
It's very strange indeed...

I made the previous test on my machine (localhost)
I uploaded the script on a remote machine and it behaves the same way, with a light difference:
- with Firefox: ok
- with Safari: double (not triple) entries

?
#4

[eluser]JHackamack[/eluser]
Keep in mind Safari has a feature of caching your most visited sites for the Top Sites feature. If your site is in the Top Sites and it comes up when a new window is open a separate HTTP request is made to cache the contents. One way to try and prevent the triple, or double inserts, is to look for a given Post variable or session variable before insert.

Check out:
http://sunpig.com/martin/archives/2010/0...ature.html
For some helpful advice also.




Theme © iAndrew 2016 - Forum software by © MyBB