开发者

How to get all table columns without defining them in query?

I have two tables, User and Company. I have joining them like this:

   $table = $this->getDbTable();
   $select = $table->select();
   $select->setIntegrityCheck( false );

   $select->from( array('User'), array( 'id' => 'id',
                                        'name' => 'User.name',
                                        'gender' => 'User.gender', 
                                        'Company_id' => 'User.Company_id' 
                                      ));

   $select->join( 'Company', 'Company.id = User.Company_id', 
                   array( 'Company_name' => 'Company.name' ,
                          'Company_address' => 'Company.address'
                         ));  

   $rows = $table->fetchAll( $select开发者_StackOverflow社区 );

It is working and giving me accurate result. Problem is that I have to mentions column names in above codes. I want to get all columns without mentioning them in above piece of code.

For example I want something like this that get all columns(But it is not providing all column values):

   $table = $this->getDbTable();
   $select = $table->select();
   $select->setIntegrityCheck( false );
   $select->from( array('User') );
   $select->join( 'Company', 'Company.id = User.Company_id' );  
   $rows = $table->fetchAll( $select );

Thanks


Leaving away the second parameter to the from call should work: http://framework.zend.com/manual/en/zend.db.select.html#zend.db.select.building.columns

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜