vexx Posted July 26, 2013 Share Posted July 26, 2013 Hey guys, I have a bit of a dilemma and I don't know what I'm doing wrong. Basically, I have this query: INSERT INTO weeklydownloads (app_id, week, weekdownloads, lastdl) VALUES ('{$this->app_id}', '{$this->week}', 1, NOW()) The query itself works just fine, however, it doesn't add the current time and date to the "lastdl" field. What this query does is actually increment a download counter for each element, for that current week of the year. The lastdl field is there only to record when was the last download made. So, what am I doing wrong here? Quote Link to comment Share on other sites More sharing options...
PravinS Posted July 26, 2013 Share Posted July 26, 2013 what is data type of field "lastdl" Quote Link to comment Share on other sites More sharing options...
vexx Posted July 26, 2013 Author Share Posted July 26, 2013 datetime Quote Link to comment Share on other sites More sharing options...
PravinS Posted July 27, 2013 Share Posted July 27, 2013 try changing its data type to timestamp Quote Link to comment Share on other sites More sharing options...
ragax Posted July 27, 2013 Share Posted July 27, 2013 Odd, though, because NOW() and datetime are normally compatible. Any idea about what might be causing this, Pravin? Quote Link to comment Share on other sites More sharing options...
PravinS Posted July 27, 2013 Share Posted July 27, 2013 actually your query should work as it is, its strange that its not working, you can try assigning "CURRENT_TIMESTAMP" as default value for "lastdl" field and remove it from INSERT query so your query will be INSERT INTO weeklydownloads (app_id, week, weekdownloads) VALUES ('{$this->app_id}', '{$this->week}', 1) may this work for you Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted July 27, 2013 Share Posted July 27, 2013 (edited) it doesn't add the current time and date to the "lastdl" field what value does it put into the field and how are you seeing what the incorrect value is in the field? some possibilities, you have another query that replaces the value after the fact with something else or if the observed symptom is due to some output from your code, you could have a logical error that is causing the wrong value to be displayed. shorter-answer: the insert query you have posted ISN'T the problem (assuming that's your actual query statement.) something else is occurring that is causing the symptom you are stating. Edited July 27, 2013 by mac_gyver Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.