开发者

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

开发者 https://www.devze.com 2023-03-29 22:19 出处:网络
I have two tables, User and Company. I have joining them like this: $table = $this->getDbTable(); $select = $table->select();

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

精彩评论

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

关注公众号