0

Here is my current code:

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

What I want now is to add the id column but as DT_RowId instead of id. How do I accomplish this? The goal would be to have all of the table columns as well as this new column.

somejkuser
  • 8,856
  • 20
  • 64
  • 130
  • Could you edit your post and add the rest of your table definition? preferably one of your current situation and one of the desired situation. – Dymen1 May 22 '17 at 09:07

2 Answers2

1

The simplest soloution would be to use the columns function with an associative array with aliases as the keys for example:

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

If you need both "old" and "new" fields, don't forget to add an asterisk.

$Select=new \Zend\Db\Sql\Select();
$Select->from($this->getTable());
$Select->columns([
  '*', 
  'DT_RowId' => 'id',
  'furtherColumn' => 'furtherColumn'
]);
akond
  • 15,865
  • 4
  • 35
  • 55