简体   繁体   中英

zf2 : join with tablegateway dont work

I tried to make a join statement with tableGateway method wich one table 'A' that retrieve a field 'bfield' from other table 'B', in this way on 'ATable' model:

public function getA($id){

    $id = (int) $id;
    $resultSet = $this->tableGateway->select( function(Select $select) use ($id) {
        $select->join( 'B' , 'B.id = A.bfield_id' , array('bfield') )
            ->where->equalTo( 'A.id' , $id );
    });

    $row = $resultSet->current();

    return $row;

}

The problema is thar it dont return the 'bfield'. There are other way to do this that work, but return a simple array, and i need that return a 'A' object because i wil bind on edit form.

Whats missing here ?

I got. I put the 'bfield' field in the model 'A' in the 'exchangeArray()' function list of vars and now it works.

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