protected function getPrimaryKeyFromFields()
{
$request = $this->getGridRequest();
if ($request == null) {
throw new Exception("You have to set " . $this->getPrimaryKey() . " before calling load()!");
}
$this->fillFieldsToGridRequest($request);
$request->setLimit(0, 1);
$request->sendNow();
$grid = $request->getGrid();
if ($grid->getTotalCount() == 0) {
throw new Exception("No rows found!");
}
if ($grid->getTotalCount() > 1) {
throw new Exception("Too many rows found!");
}
$recordset = $grid->getRecordset();
foreach ($recordset as $record) {
$this->setField($this->getPrimaryKey(), $record->get($this->getPrimaryKey()));
break;
}
}