Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
How to set condition in creating relation
I've two modals "
" & "
User has many packages
but I need only last package that is not expired.
so I wrote this relation in
protected static $_has_many = array(
'package' => array(
'key_from' => 'id',
'model_to' => 'Model_Packagecart',
'key_to' => 'user_id',
'conditions' => array(
'order_by' => array(
'id' => 'DESC'
But this shows error in Where condition, Also limit doesnot work but if i place
Can Anyone say what should I do?
to get the last unexpired row??
The problem here seems to be your lack of PHP knowledge.
You are using the function time() in a variable definition, and you are not allowed to, so that is the PHP syntax error you are getting.
If you want define conditions based on runtime information, you need to use the init class method:
* filter packages on expiration timestamp
public static function _init()
// add a where clause, we need DB::expr here, we're injecting a literal
static::$_has_many['package']['conditions']['where'] = array(array(['expired_at', '>', \DB::expr(time())));
Add a Comment
It looks like you're new here. If you want to get involved, click one of these buttons!
Apply for Membership
↳ Job Board
↳ Installation & Setup
↳ Tips and Tutorials
↳ Code share
In this Discussion