F3 Cortex and Many to Many relation

512 Views Asked by At

I'm building a simple app using F3 and Cortex but I'm running in some problems trying to create a simple Many to Many relation. Its just two tables (and a third, from the relation), the tables already exist and have some data:

class User extends \DB\Cortex {

protected
        $fieldConf = array(
            'name' => array (
                'type' => 'VARCHAR128',
                'nullable' => false,
                'required' => true,
                ),
            'email' => array (
                'type' => 'VARCHAR256',
                'nullable' => false,
                'required' => true,
                ),
            'password' => array (
                'type' => 'VARCHAR128',
                'nullable' => false,
                'required' => true,
                ),
//                'groups' => array(
//                    'has-many' => array('Group', 'group_id', 'user_has_group')
//                )
                ),
        $db = 'db',
        $table = 'user';
}

and

class Group extends \DB\Cortex {

protected
        $fieldConf = array(
            'name' => array(
                'type' => 'VARCHAR128',
                'nullable' => false,
                'required' => true,
            ),
            'description' => array(
                'type' => 'VARCHAR128',
                'nullable' => false,
                'required' => true,
            ),
//                'users' => array(
//                    'has-many' => array('User', 'user_id', 'user_has_group')
//                )
                ),
        $db = 'db',
        $table = 'group';
}

accourind with this model of the database

But if I remove those comment marks, I get a strange error while acessing anything:

Internal Server Error No valid DB Connection given.

And on refresh:

Internal Server Error Fatal error: Leaked 1 hashtable iterators

It looks silly, but I searched all over and spent the better part of a whole day, and still can't seem to make it work.

0

There are 0 best solutions below