create table tbl_doc (
doc_id integer NOT NULL PRIMARY KEY AUTO_INCREMENT,
doc_type integer NOT NULL
);
create table tbl_programmer (
programmer varchar(100) not null,
primary key (programmer)
);
create table tbl_lookup_programmer (
doc_id integer not null,
programmer varchar(100) not null,
primary key (doc_id, programmer),
foreign key (doc_id) references tbl_doc (doc_id)
on delete cascade,
foreign key (programmer) references tbl_programmer (programmer)
on update cascade on delete cascade
);
The programmer and lookup_programmer tables provide a means to associate one or many programmers to every doc_id. There is no programmer column in the doc table.
SELECT * FROM `tbl_doc` `t` WHERE `t`.`doc_id`=1 LIMIT 1
just returns doc_id and doc_type from the table, doc.
I would like for the doc model to return the same row with a comma delimited list of programmers. Not sure how to do this nicely within Yii without writing up a complex query.
I see that Yii’s query is correct and I get the right data in PHPMYADMIN, but I am unable to see the “programmers” attribute being populated. Not sure where Yii put it.
I can still get the expected output if I delete the ‘select’ and ‘group’ above and just manually iterate through them…I guess this is the only way then.