• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Calculate 2 fields with Active records

#1
I have a table with fields
[Image: Rz9ByFZ_RUGgBsAsGxTaiA.png]

I want to looking for some records expired date in 6days.
today - test_time (created date) < duration - 6 days

My code don't work
Code:
$this->db->select("test.*");

$this->db->from('test');

$current_time = time();
$pre7day = $current_time - 7*60*60*24;
$next7day = $current_time + 7*60*60*24;
$this->db->where("duration * con <=", $next7day);
return $this->db->get();
This is a error:
Quote:Error Number: 1064

You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '`con` <= 1508605807' at line 3

SELECT `ospos_test`.*FROM `ospos_test`WHERE `duration *` `con` <= 1508605807

Filename: vendor/codeigniter/framework/system/database/DB_driver.php

Line Number: 691

Please help me.

Thanks.
ho
Reply

#2
Try:
PHP Code:
$this->db->where("(duration * con) <="$next7day); 
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.