Welcome Guest, Not a member yet? Register   Sign In
problem with where clause!!!
#1

[eluser]immi[/eluser]
Hi

I am making a page which display videos on controller i added microtime(true) for table field 'lastwatch'. I want to grab the records on a page where lastwatch is lower than 300 seconds but it makes me error
Code:
function sqldiff($time){
    return $time - microtime(true);

}
$data["q"] = $this->db->query("SELECT * from vid_info where sqldiff(lastwatch)< 100 order by lwatch desc")->num_rows();


I get this error
Quote:A Database Error Occurred
Error Number: 1305

FUNCTION mujrahome.sqldiff does not exist

SELECT * from vid_info where sqldiff(lastwatch)<= 100 order by lwatch desc


KINDLY HELP!!!
#2

[eluser]JHackamack[/eluser]
You can't mix a PHP function with a mysql column. Take a look at MySQL Timestamp Diff:
http://dev.mysql.com/doc/refman/5.5/en/d...n_timediff
#3

[eluser]immi[/eluser]
thanks! I have turned it different way like this

$value = microtime(true) - 2000;
$value = $this->db->escape($value);
$config['total_rows'] = $this->db->query("SELECT * from vid_info where lwatch > $value order by lwatch desc")->num_rows();


Thnx




Theme © iAndrew 2016 - Forum software by © MyBB