Zend Framework 2 Db\Adapter\Adapter query resultset like ZF1

后端 未结 5 1316
情深已故
情深已故 2021-02-08 15:36

Just need a hand understanding some simple database queries in ZF2. In ZF1 I have simple methods like this:

public function recordset()
{
// listing of all reco         


        
5条回答
  •  北海茫月
    2021-02-08 16:08

    You can avoid the foreach loop by doing the following:

    $statement = $db->query($sql);
    
    /** @var $results Zend\Db\ResultSet\ResultSet */
    $results = $statement->execute();
    
    $data = $result->getResource()->fetchAll();
    // Now data is an array
    

提交回复
热议问题