phalcon - Get Related Records Fails -



phalcon - Get Related Records Fails -

i'm having problem getting phalcon orm load related records. simple illustration code truncated brevity: can tell me why calls related tables "forget" foreign key parent table?

for given table users, there can many useraddrs

create table `users` ( `id` int(10) unsigned not null auto_increment, ..... primary key (`id`), unique key `password_unique` (`password`) ) engine=innodb auto_increment=2806 default charset=latin1

and../

create table `user_addrs` ( `id` int(10) unsigned not null auto_increment, `users_id` int(10) unsigned not null primary key (`id`), key `fk_user_addrs_users1_idx` (`users_id`), constraint `fk_user_addrs_users1` foreign key (`users_id`) references `users` (`id`) on delete cascade on update cascade ) engine=innodb auto_increment=15 default charset=latin1

/models/users.php

public function initialize() { $this->hasmany("id", "phalconrest\models\useraddrs", "users_id", array('alias' => 'useraddrs'));

/models/useraddrs.php

public function initialize() { $this->belongsto('users_id', 'phalconrest\models\users', 'id', array('alias' => 'users'));

this code....

$user = users::findfirst($id); $useraddrsrecs = $user->useraddrs->toarray();

gets me...

select `users`.`id` `users` `users`.`id` = 103 limit :1 select if(count(*)>0, 1 , 0) `information_schema`.`tables` `table_name`='user_addrs' describe `user_addrs` select `user_addrs`.`id` `user_addrs` `user_addrs`.`users_id` = :0

question: why phone call user_addrs forget related record users.id 103?

phalcon

Comments

Popular posts from this blog

php - How to pass multiple values from url -

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

database - php search bar when I press submit with nothing in the search bar it shows all the data -