/**
* @param TActiveRecord $record
* @return TDataGatewayCommand
*/
public function getCommand(TActiveRecord $record)
{
$conn = $record->getDbConnection();
$connStr = $conn->getConnectionString();
$tableInfo = $this->getRecordTableInfo($record);
if (!isset($this->_commandBuilders[$connStr])) {
$builder = $tableInfo->createCommandBuilder($record->getDbConnection());
$command = new TDataGatewayCommand($builder);
$command->OnCreateCommand[] = array($this, 'onCreateCommand');
$command->OnExecuteCommand[] = array($this, 'onExecuteCommand');
$this->_commandBuilders[$connStr] = $command;
}
$this->_commandBuilders[$connStr]->getBuilder()->setTableInfo($tableInfo);
$this->_currentRecord = $record;
return $this->_commandBuilders[$connStr];
}