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? Link to comment https://forums.phpfreaks.com/topic/280540-strange-query-results/ Share on other sites More sharing options...
PravinS Posted July 26, 2013 Share Posted July 26, 2013 what is data type of field "lastdl" Link to comment https://forums.phpfreaks.com/topic/280540-strange-query-results/#findComment-1442266 Share on other sites More sharing options...
vexx Posted July 26, 2013 Author Share Posted July 26, 2013 datetime Link to comment https://forums.phpfreaks.com/topic/280540-strange-query-results/#findComment-1442273 Share on other sites More sharing options...
PravinS Posted July 27, 2013 Share Posted July 27, 2013 try changing its data type to timestamp Link to comment https://forums.phpfreaks.com/topic/280540-strange-query-results/#findComment-1442366 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? Link to comment https://forums.phpfreaks.com/topic/280540-strange-query-results/#findComment-1442370 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 Link to comment https://forums.phpfreaks.com/topic/280540-strange-query-results/#findComment-1442371 Share on other sites More sharing options...
mac_gyver Posted July 27, 2013 Share Posted July 27, 2013 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. Link to comment https://forums.phpfreaks.com/topic/280540-strange-query-results/#findComment-1442408 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.