I want to build a query like
SELECT username from users
WHERE login_attempts > 3 AND last_attempt_time < 24 (hours).
I have 2 questions to build the above query.
-
I’m storing the date in last_attempt_time in DATETIME format (2011-06-16 10:29:23)
Can I directly select some row which has time difference less than 24 hours from now? (OR do I have to select a row, and then check with for example PHP the time difference? ) -
How can I write this query using CodeIgniter Active Record? (Do I need to use get_where?) I could not find any related example in their documentation.
Thanks.
Try this:
You can find the complete documentation here: http://codeigniter.com/user_guide/database/active_record.html#select.