Search code examples
phpdatabaseactiverecordphpactiverecord

phpactiverecord: get objects related by condition


I'm using ActiveRecord with a database already exists. I need get all accounts related with a personan with account_type = 'A' so I have:

class Person extends ActiveRecord\Model {

static $has_many = array(
    array(
        'accounts',
        'conditions' => array('account_type = ?' => array('A')),
        'class_name' => 'Accounts',
        'foreign_key' => 'idpersona'
    )
);

But I get the error No bound parameter for index 3. I tried to remove the line 'conditions' => array('account_type = ?' => array('A')) and the app works fine. What I am doing wrong?


Solution

  • The "syntax" is different, conditions should be an array like array('account_type = ?', 'A')