添加列以选择对象 Zend 框架



这是我当前的代码:

$Select=new Select();
$Select->from($this->getTable());

我现在想要的是添加id columnDT_RowId而不是id。我该如何实现此目的?目标是拥有所有表列以及此新列。

如果您同时需要"旧"和"新"字段,请不要忘记添加星号。

$Select=new ZendDbSqlSelect();
$Select->from($this->getTable());
$Select->columns([
  '*', 
  'DT_RowId' => 'id',
  'furtherColumn' => 'furtherColumn'
]);

最简单的解决方法是将列函数与以别名作为键的关联数组一起使用,例如:

$select=new Select();
$select->from($this->getTable());
$select->columns(array(
 'DT_RowId' => 'id',
 'furtherColumn' => 'furtherColumn',
));

最新更新