简体   繁体   中英

How do I JOIN one-to-many tables using NotORM lib

i'm using NotOrm lib for working with data in the database. I have to follow the instructions here http://www.sitepoint.com/database-interaction-made-easy-with-notorm/

but did not solve my problem Here is my data structure:

Tables 
   -members 
           ---Indexes 
            PRIMARY id 

   -cards
          ---Indexes 
            PRIMARY id
            INDEX   member_id
          ---Foreign keys
            member_id   members(id) CASCADE CASCADE

I used sql command

ALTER TABLE  `cards` ADD FOREIGN KEY (  `member_id` ) REFERENCES  `xxx`.`members` (`id`)
     ON DELETE CASCADE ON UPDATE CASCADE ;

my code

$cards = $this->db->cards();    
    foreach($cards as $c){
        //echo "here";
        echo $c->members["member_id"];
    }

and response is

=> Message: Undefined index: members_id

Is my data structure correct for using NotORM ? i want to result from SQL as:

select members.f1, members.f2 from members join cards on members.id = cards.member_id where cards.email like '%%' or cards.phone like '%%'

Many thanks!

在论坛上也有人问过并回答了这个问题

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM