Jump to content

CI2 Active Record Class: return recordsets using MYSQL functions??


lak

Recommended Posts

In MySQL this would read as

 

SELECT *

FROM querydate

WHERE dateposted >= (

SELECT SUBDATE( CURRENT_DATE, INTERVAL 14

DAY ) AS LASTDATE )

AND dateposted <= CURRENT_DATE

 

Returning records that are NOT more than 14 days from current date

 

so if i do this in CI2

 

$lastdate=$this->db->query(SELECT SUBDATE( CURRENT_DATE, INTERVAL 14 DAY ) AS LASTDATE );

$currdate=$this->db->query(SELECT CURRENT_DATE AS CURRDATE);

 

$this->db->select();

$this->db->get(querydate);

$this->db->where('dateposted=>',$lastdate);

$this->db->where('dateposted<=',$currdate);

 

Any MASTER JEDI who can confirm that this absolutely theoritically CORRECT?

 

Many thanks.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.