Search code examples
phpmysqlnette

MySQL statement with ">" or "<" parameter


Is there a way how to fetch all data from table where number is higher than something.

In my case I am using UNIX time in database to be able to easily compare data. Right now I would like to count every login which is higher then current UNIX time minus 24 hours.

Is there a way how I can write it? I was thinking about something like this but not sure how can I write SQL statement with < or >.

function getDailyOnline()
{
    return $this->db->table('users')
        ->where('last_login', $post->id);
}   

I need SQL command, don't need to use Nette Framework as I do in my "example".


Solution

  • You can simply try this:

    $this->db->table('users')->where('last_login > ', $post->id);