Bravo3\Orm\Mappers\Metadata\Entity::getIdColumns PHP Method

getIdColumns() public method

Get all columns that are marked an as an ID field
public getIdColumns ( ) : Column[]
return Column[]
    public function getIdColumns()
    {
        if ($this->id_columns === null) {
            $this->id_columns = [];
            foreach ($this->columns as $column) {
                if ($column->isId()) {
                    $this->id_columns[] = $column;
                }
            }
        }
        return $this->id_columns;
    }

Usage Example

Example #1
0
 /**
  * Get an ID for the given data
  *
  * @return string
  */
 public function getId()
 {
     $values = [];
     foreach ($this->metadata->getIdColumns() as $column) {
         $values[] = $this->getPropertyValue($column->getProperty());
     }
     if (!count($values)) {
         throw new InvalidEntityException('Entity "' . $this->metadata->getClassName() . '" has no ID column');
     }
     return implode(self::ID_DELIMITER, $values);
 }