codeigniter-base-model
codeigniter-base-model copied to clipboard
Limit to relate model
Is there any way to limit database results for relate model? For example:
$this->some_model_one->with('some_model_two')->get('model_one_primary_key').
I want to limit number of 'some_model_two' results.
Model one has_many of some_model_two.
You should be able to limit the number of results by chaining ->limit(x) inside your call.
Line 762-769 of My_Model:
/**
* A wrapper to $this->_database->limit()
*/
public function limit($limit, $offset = 0)
{
$this->_database->limit($limit, $offset);
return $this;
}