我是 ZF 的新手,下面有一个代码。我尝试获取自定义列并加入 sql select,但失败了。我尝试使用搜索,但没有找到任何结果。告诉我如何进行更复杂查询的示例。谢谢。
<?php
namespace FcFlight\Model;
use Zend\Db\TableGateway\AbstractTableGateway;
use Zend\Db\Adapter\Adapter;
use Zend\Db\ResultSet\ResultSet;
use Zend\Db\Sql\Select;
use FcFlight\Filter\FlightHeaderFilter;
class FlightHeaderModel extends AbstractTableGateway
{
/**
* @var string
*/
protected $table = 'flightBaseHeaderForm';
/**
* @param \Zend\Db\Adapter\Adapter $adapter
*/
public function __construct(Adapter $adapter)
{
$this->adapter = $adapter;
$this->resultSetPrototype = new ResultSet();
$this->resultSetPrototype->setArrayObjectPrototype(new FlightHeaderFilter($this->adapter));
$this->initialize();
}
/**
* @param $id
* @return array|\ArrayObject|null
* @throws \Exception
*/
public function get($id)
{
$id = (int)$id;
$rowSet = $this->select(array('id' => $id));
$row = $rowSet->current();
if (!$row) {
throw new \Exception("Could not find row $id");
}
$row->dateOrder = date('Y-m-d', $row->dateOrder);
return $row;
}
}