Welcome Guest, Not a member yet? Register   Sign In
Problem with associations
#4

[eluser]Carmichael[/eluser]
Code:
class Permission extends ActiveRecord\Model
{
    static $has_many = array(
        array('groups'),
        array('groups', 'through' => 'permissions_map', 'foreign_key' => 'group_id'),
    );

}

class Group extends ActiveRecord\Model
{
    
    static $has_many = array(
         array('permissions', 'class_name' => 'Permission', 'foreign_key' => 'group_id')
    );
    
    public function get_group_permissions($groupId)
    {
        $permissions = Group::find($groupId);
        return $permissions;
        
    }
    
}

view
Code:
<?php foreach($permissions as $permission): ?>

    <?php echo $permission->name; ?>

<?php endforeach; ?>

Doesn't work...this is hard as fuck and the ORM documentation sucks...



Messages In This Thread
Problem with associations - by El Forum - 07-03-2012, 03:49 PM
Problem with associations - by El Forum - 07-04-2012, 07:03 AM
Problem with associations - by El Forum - 07-04-2012, 12:42 PM
Problem with associations - by El Forum - 07-04-2012, 01:51 PM



Theme © iAndrew 2016 - Forum software by © MyBB