1:M issue

29 views
Skip to first unread message

whytewolf

unread,
Jan 11, 2012, 6:20:03 PM1/11/12
to NotORM
I'm having a strange issue with trying to get reference working with
NotORM [current git version]

user
+ id
+ username
+ password
+ role_id
+ access_key
+ secret_key
+ timestamp
role
+ id
+ role_name

$row = $db-
>user[1];
$username =
$row['username'];
$access_key =
$row['access_key'];
$secret_key =
$row['security_key'];
$role = $row->role['role_name'];


everything besides the reference is working fine. the reference at the
end comes out as null, and if i change it to (string) $row->role() the
sql query shows as
SELECT * FROM role WHERE (role.user_id IN (1)) this is backwards from
what i was expecting. also the value in the IN set is the primary id
from the user table.
am i just using this wrong?

whytewolf

unread,
Jan 17, 2012, 1:21:02 PM1/17/12
to not...@googlegroups.com
so pressing on even further. I have 2 more tables like such

rolepermissions
role_id
permissions_id

permissions
id
permission_name

foreach($row2->rolepermissions() as $role) {                                                                                                                                        
    echo (string )$role->permissions();                                                                                                                            
}     

this shows SELECT * FROM permissions WHERE (permissions.rolepermissions_id IN (0, 1))SELECT * FROM permissions WHERE (permissions.rolepermissions_id IN (0, 1))
[twice since there are two rows returned from the $row2->rolepermissions() query] 

this goes against what the notorm front page says 

this code should line up with 
foreach ($application->application_tag() as $application_tag) { // get all tags of $application
   echo $application_tag->tag["name"] . "\n"; // print the tag name
}


whytewolf

unread,
Jan 17, 2012, 5:23:14 PM1/17/12
to not...@googlegroups.com
never mind, after going through the notorm source code, then running somes tests, it is working now. only things i changed was moving from the NotORM_Structure_Discovery to the NotORM_Structure_Convention [but that was days ago] and adding a reference for the user.role_id to role.id [which the source code doesn't even check]
Reply all
Reply to author
Forward
0 new messages