Welcome Guest, Not a member yet? Register   Sign In
ActiveRecord, MySQL with DATE_SUB ... how?
#1

[eluser]hugle[/eluser]
Hello Everyone,

I'm trying to grab data, from database, which is older than 30 days:

I'll paste the live example, so it would be easier to understand...
Code:
$this->db->select('`favorites`.*, `razrabotki`.`name` AS `name`, `razrabotki`.`text` AS `text`, `razrabotki`.`created` AS `created2`');
$this->db->where(array('user_id' => $this->user_id, 'class_id' => '3'));
//$this->db->where('DATE_SUB(CURDATE(),INTERVAL 30 DAY) > `created2`');
$this->db->join('users', 'users.id = favorites.user_id', 'left');
$this->db->join('razrabotki', 'razrabotki.id = favorites.item_id', 'left');
$this->db->order_by("favorites.id", "desc");
$out = $this->db->get($this->_table)->result_array();

as you noted, the line #3 is commented out, since if I activate it, I get MySQL errors...

maybe this line $this->db->where('DATE_SUB(CURDATE(),INTERVAL 30 DAY) > `created2`')
should be described somehow in other way? I've already tried differend approaches... but with no luckSad

Maybe you guys could point me on direction?
I like ActiveRecord style so much!Smile

THank you!


Messages In This Thread
ActiveRecord, MySQL with DATE_SUB ... how? - by El Forum - 10-04-2009, 11:12 AM
ActiveRecord, MySQL with DATE_SUB ... how? - by El Forum - 10-04-2009, 03:33 PM
ActiveRecord, MySQL with DATE_SUB ... how? - by El Forum - 10-04-2009, 04:20 PM
ActiveRecord, MySQL with DATE_SUB ... how? - by El Forum - 10-04-2009, 04:39 PM
ActiveRecord, MySQL with DATE_SUB ... how? - by El Forum - 10-04-2009, 04:44 PM
ActiveRecord, MySQL with DATE_SUB ... how? - by El Forum - 10-06-2009, 04:25 PM



Theme © iAndrew 2016 - Forum software by © MyBB