Nette\Database\Table\Selection::getPrimary PHP Method

getPrimary() public method

public getPrimary ( $need = TRUE ) : string | array | null
return string | array | null
    public function getPrimary($need = TRUE)
    {
        if ($this->primary === NULL && $need) {
            throw new \LogicException("Table '{$this->name}' does not have a primary key.");
        }
        return $this->primary;
    }

Usage Example

 /**
  * @return int
  */
 public function getCount()
 {
     if ($this->count === NULL) {
         $column = !$this->source->getPrimary(FALSE) ? '*' : $this->source->getPrimary();
         $this->count = $this->source->count($column);
     }
     return $this->count;
 }
All Usage Examples Of Nette\Database\Table\Selection::getPrimary