I wrote an untrivial sql statement that I need to run in CSqlDataProvider.
$sql = <<<EOF
{$this->dbConnection->createCommand()
->select()
->from($this->tableName())
->where($criteria->condition)
->limit($pagination->limit, $pagination->offset)
->text}
UNION ALL
{$this->dbConnection->createCommand()
->select()
->from($pendingRetireInventory->tableName())
->where($criteria_pendingRetire->condition)
->limit($pagination->limit, $pagination->offset)
->text}
UNION ALL
{$this->dbConnection->createCommand()
->select()
->from($sparesInventory->tableName())
->where($criteria_spares->condition)
->limit($pagination->limit, $pagination->offset)
->text}
UNION ALL
{$this->dbConnection->createCommand()
->select()
->from($stagingInventory->tableName())
->where($criteria_staging->condition)
->text}
EOF;
return new CSqlDataProvider($this->dbConnection->createCommand($sql), array(
'params' => $criteria->params + $criteria_pendingRetire->params + $criteria_spares->params + $criteria_staging->params,
'totalItemCount' => $this->dbConnection->createCommand($sqlCount)->queryScalar($criteria->params + $criteria_pendingRetire->params + $criteria_spares->params + $criteria_staging->params),
'sort' => $sort,
));
Why does CSqlDataProvider overwrite my primary key ‘id’ with its internal rowId?
I need the right primary key so I can use that for the update, delete and view buttons.
Can somebody help me to figure this out?