codeigniter-base-model icon indicating copy to clipboard operation
codeigniter-base-model copied to clipboard

Feature request: get by date range

Open fcosrno opened this issue 11 years ago • 2 comments
trafficstars

Something like this:

$from = strtotime('yesterday');
$to = strtotime('today');
$this->blog_model->get_by_date_range($from,$to)->limit(10);

This would look at 'created_at' and do the equivalent of this:

$this->db->where("UNIX_TIMESTAMP(created_at)>=".$from);
$this->db->where("UNIX_TIMESTAMP(created_at)<=".$to);

Maybe the third parameter can be optional for another date field instead.

$this->blog_model->get_by_date_range($from,$to,'updated_at')->limit(10);

Thanks for this project. Makes my CodeIgniter feel like Laravel. :)

fcosrno avatar Apr 01 '14 03:04 fcosrno

I think this would be outside of the scope of a base model. Since your model extends the base model, this would be added to your model (as an extension).

If you use it often, a blog for example, the you could extend the base model with a blog base model (from which you would then extend with the model).

kbjohnson90 avatar Apr 01 '14 17:04 kbjohnson90

What Kyle said :-)

On 1 April 2014 18:48, Kyle B. Johnson [email protected] wrote:

I think this would be outside of the scope of a base model. Since your model extends the base model, this would be added to your model (as an extension).

If you use it often, a blog for example, the you could extend the base model with a blog base model (from which you would then extend with the model).

Reply to this email directly or view it on GitHubhttps://github.com/jamierumbelow/codeigniter-base-model/issues/164#issuecomment-39236046 .

Jamie Rumbelow [email protected]

jamierumbelow avatar Apr 01 '14 17:04 jamierumbelow