public getPrimary ( $need = TRUE ) : mixed | ||
return | mixed | possible int, string, array, object (Nette\Utils\DateTime) |
public function getPrimary($need = TRUE)
{
$primary = $this->table->getPrimary($need);
if ($primary === NULL) {
return NULL;
} elseif (!is_array($primary)) {
if (isset($this->data[$primary])) {
return $this->data[$primary];
} elseif ($need) {
throw new Nette\InvalidStateException("Row does not contain primary {$primary} column data.");
} else {
return NULL;
}
} else {
$primaryVal = [];
foreach ($primary as $key) {
if (!isset($this->data[$key])) {
if ($need) {
throw new Nette\InvalidStateException("Row does not contain primary {$key} column data.");
} else {
return NULL;
}
}
$primaryVal[$key] = $this->data[$key];
}
return $primaryVal;
}
}
/** * Returns primary key value. * * @param $need bool * @return mixed possible int, string, array, object (Nette\Utils\DateTime) */ public function getPrimary($need = TRUE) { return $this->activeRow->getPrimary($need); }