[Cakephp 2.8.1] Multiple assosication to one model with habtm throws a notice

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[Cakephp 2.8.1] Multiple assosication to one model with habtm throws a notice

CakePHP mailing list
Hello Cakephp Fans,

today i receive these error:

Notice (8): Undefined index: User [CORE\Cake\Model\Datasource\DboSource.php, line 1388]

Its easy to reproduce:

Model: User belongsTo Group
Model: Permission habtm Rights (className User)
Permission habtm Owners (className User)

When i use now
$this->Permission->find('all', array('recursive' => -2));

the notice will be thrown. But only for the 2nd habtm.

The output is like:
array(
       
'Permission' => array(
               
'id' => '6',
       
),
       
'Owner' => array(
               
(int) 0 => array(
                       
'id' => '499',
                       
'PermissionOwner' => array(
                               
'id' => '6',
                               
'user_id' => '499',
                               
'permission_id' => '6'
                       
)
               
)
       
),
       
'Rights' => array(
               
(int) 0 => array(
                       
'id' => '485',
                       
'PermissionRight' => array(
                               
'id' => '18',
                               
'permission_id' => '6',
                               
'user_id' => '485',
                       
),
                       
'Group' => array()
               
),
               
(int) 1 => array(
                       
'id' => '124',
'PermissionRight'                                'id' => '19',
                               
'permission_id' => '6',
                               
'user_id' => '124',
                       
),
                       
'Group' => array()
               
)
       
)
)



Kind Regards

--
Sign up for our Newsletter for updates.
http://cakephp.org/newsletter/signup
 
We will soon be closing this Google Group. But don't worry, we have something better coming. Stay tuned for an updated from the CakePHP Team soon.
 
Like Us on FaceBook https://www.facebook.com/CakePHP
Follow us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Cakephp 2.8.1] Multiple assosication to one model with habtm throws a notice

John Andersen
Check your model names in the HABTM relationships. Looks like you have a mix of singular and plural.
Enjoy, John

On Monday, 14 March 2016 05:33:36 UTC+2, Steffen Reinig wrote:
Hello Cakephp Fans,

today i receive these error:

Notice (8): Undefined index: User [CORE\Cake\Model\Datasource\DboSource.php, line 1388]

Its easy to reproduce:

Model: User belongsTo Group
Model: Permission habtm Rights (className User)
Permission habtm Owners (className User)

When i use now
$this->Permission->find('all', array('recursive' => -2));

the notice will be thrown. But only for the 2nd habtm.

The output is like:
array(
       
'Permission' => array(
               
'id' => '6',
       
),
       
'Owner' => array(
               
(int) 0 => array(
                       
'id' => '499',
                       
'PermissionOwner' => array(
                               
'id' => '6',
                               
'user_id' => '499',
                               
'permission_id' => '6'
                       
)
               
)
       
),
       
'Rights' => array(
               
(int) 0 => array(
                       
'id' => '485',
                       
'PermissionRight' => array(
                               
'id' => '18',
                               
'permission_id' => '6',
                               
'user_id' => '485',
                       
),
                       
'Group' => array()
               
),
               
(int) 1 => array(
                       
'id' => '124',
'PermissionRight'                                'id' => '19',
                               
'permission_id' => '6',
                               
'user_id' => '124',
                       
),
                       
'Group' => array()
               
)
       
)
)



Kind Regards

--
Sign up for our Newsletter for updates.
http://cakephp.org/newsletter/signup
 
We will soon be closing this Google Group. But don't worry, we have something better coming. Stay tuned for an updated from the CakePHP Team soon.
 
Like Us on FaceBook https://www.facebook.com/CakePHP
Follow us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Cakephp 2.8.1] Multiple assosication to one model with habtm throws a notice

CakePHP mailing list
Hi,

i checked your solution, but it occurs the same error.

    public $hasAndBelongsToMany = array (
           
'Owners' => array (
                   
'className' => 'User',
                   
'with' => 'PermissionOwner',
           
),
           
'Rights' => array (
                   
'className' => 'User',
                   
'with' => 'PermissionRight',
           
)
   
);

Notice (8): Undefined index: User [CORE\Cake\Model\Datasource\DboSource.php, line 1388]



On Monday, March 14, 2016 at 8:29:13 PM UTC+1, John Andersen wrote:
Check your model names in the HABTM relationships. Looks like you have a mix of singular and plural.
Enjoy, John

On Monday, 14 March 2016 05:33:36 UTC+2, Steffen Reinig wrote:
Hello Cakephp Fans,

today i receive these error:

Notice (8): Undefined index: User [CORE\Cake\Model\Datasource\DboSource.php, line 1388]

Its easy to reproduce:

Model: User belongsTo Group
Model: Permission habtm Rights (className User)
Permission habtm Owners (className User)

When i use now
$this->Permission->find('all', array('recursive' => -2));

the notice will be thrown. But only for the 2nd habtm.

The output is like:
array(
       
'Permission' => array(
               
'id' => '6',
       
),
       
'Owner' => array(
               
(int) 0 => array(
                       
'id' => '499',
                       
'PermissionOwner' => array(
                               
'id' => '6',
                               
'user_id' => '499',
                               
'permission_id' => '6'
                       
)
               
)
       
),
       
'Rights' => array(
               
(int) 0 => array(
                       
'id' => '485',
                       
'PermissionRight' => array(
                               
'id' => '18',
                               
'permission_id' => '6',
                               
'user_id' => '485',
                       
),
                       
'Group' => array()
               
),
               
(int) 1 => array(
                       
'id' => '124',
'PermissionRight'                                'id' => '19',
                               
'permission_id' => '6',
                               
'user_id' => '124',
                       
),
                       
'Group' => array()
               
)
       
)
)



Kind Regards

--
Sign up for our Newsletter for updates.
http://cakephp.org/newsletter/signup
 
We will soon be closing this Google Group. But don't worry, we have something better coming. Stay tuned for an updated from the CakePHP Team soon.
 
Like Us on FaceBook https://www.facebook.com/CakePHP
Follow us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.