2008年12月11日星期四

Re: [fw-db] overwriting colun problem

You need to specify all the columns you need from the second table. 'Cause
now you're taking all the name-columns, Role.id as Role_id AND all the
role-columns.

so it needs to be something like this

$select->from('Name')
->join('Role','Role.name_id = Name.id', array('id AS
role_id','name_id','Suranme')
->group('Name.id');


Aniketto wrote:
>
> I have two table Name and Role as below
>
> Name is
> id int(3) primary key,
> myname varchar(10),
> age int (3)
>
> Role table is
> id int (2) primary key,
> name_id(3) foreign key references Name.id
> Suranme varchar(20)
>
> Now I write a query
> $select->setIntegrityCheck(false)
> ->from('Name',
> array('Name.*', 'role_id'=>'Role.id',
> )
> ->join('Role', 'Role.name_id = Name.id')
> ->group('Name.id')
>
> echo $select->__toString();
>
> It printd select 'Name.*', 'Role.id' as 'role_id', Role.* from Name, Role
> where Name.Nid = Role.id
>
> Now the id columns valu in Name table get overridden by id column in Role.
> What can be done to avoid that?
>
>


-----
visit my website at http://www.phpscriptor.com/ http://www.phpscriptor.com/
--
View this message in context: http://www.nabble.com/overwriting-colun-problem-tp20970716p20970928.html
Sent from the Zend DB mailing list archive at Nabble.com.

没有评论: