Returns an array of Properties that form the primary keys
@return array
766375
public function primary()
    {
        $columns = array_filter($this->_props, function($property) {
            return $property->type->options()->primary;
        });

        if(empty($columns))
            throw new Exception("No primary key defined for {$this->_class}");

        return $columns;
    }
444355
public function getPrimaryKey() {
        return $this->cache(__METHOD__, function() {
            $pk = $this->getConfig('primaryKey');
            $schema = $this->getSchema();

            if ($schema->hasColumn($pk)) {
                return $pk;
            }

            if ($pk = $schema->getPrimaryKey()) {
                return $pk['columns'][0];
            }

            return 'id';
        });
    }
1297238
public function keySet()
    {
        $result = [];
        $keys = $this->keys();
        foreach ($keys as $key) {
            $result[] = $key;
        }

        return $result;
    }
525326
public function getOtherRequiredPrimaryKeys(array $primaryKeys)
    {
        $pks = [];
        foreach ($this->getPrimaryKey() as $primaryKey) {
            if ($primaryKey->isNotNull() && !$primaryKey->hasDefaultValue() && !in_array($primaryKey, $primaryKeys, true)) {
                $pks = $primaryKey;
            }
        }

        return $pks;
    }
387342
public function getPropertiesNames() {
		$propertiesList = [];
		
		foreach($this->_data as $item) {
			$propertiesList += array_keys($item);
		}
		
		return $propertiesList;
	}
1129843
public function getColumns()
    {
        $primaryKey        = $this->getPrimaryKey();
        $primaryKeyColumns = [];

        if ($primaryKey !== null) {
            $primaryKeyColumns = $this->filterColumns($primaryKey->getColumns());
        }

        return array_merge($primaryKeyColumns, $this->getForeignKeyColumns(), $this->_columns);
    }
1302984
public function getIndexedProperties()
    {
        $props = [];
        foreach ($this->properties as $property) {
            if ($property->isIndexed()) {
                $props[] = $property;
            }
        }

        return $props;
    }
1371775
public function getPrimaryKey()
    {
        if (null == $this->primaryKey) {
            foreach ($this->getFields() as $field) {
                if ($field->isPrimaryKey()) {
                    $this->primaryKey = $field;
                    break;
                }
            }
        }
        return $this->primaryKey;
    }
118006
public function getPrimaryKeys(): array
    {
        $primaryColumns = [];
        foreach ($this->getColumns() as $column) {
            if ($column->getAbstractType() == 'primary' || $column->getAbstractType() == 'bigPrimary') {
                if (!in_array($column->getName(), $this->primaryKeys)) {
                    //Only columns not listed as primary keys already
                    $primaryColumns[] = $column->getName();
                }
            }
        }

        return array_unique(array_merge($this->primaryKeys, $primaryColumns));
    }
817636
public function getPrimaryKeyName()
    {
        if (!isset($this->primaryKeyName)) {
            // lazy load
            $memory = $this->getDI()->get('memory');
            $attributes = $memory->getPrimaryKeyAttributes($this);
            $attributeKey = $attributes[0];

            // adjust for colMaps if any are provided
            $colMap = $memory->getColumnMap($this);
            if (is_null($colMap)) {
                $this->primaryKeyName = $attributeKey;
            } else {
                $this->primaryKeyName = $colMap[$attributeKey];
            }
        }
        return $this->primaryKeyName;
    }
394860
protected function getTableFields() {
        $data = array_keys($this->rules());
        if (!empty($this->primaryKey)) {
            $data[] = $this->primaryKey;
        }
        return $data;
    }
216754
protected function buildMapperPrimaryKeys()
    {

        $fields = array();

        foreach ($this->columns as $column) {
            if ($column->isPrimaryKey()) {
                $fields[] = "        '" . $column->getName() . "'";
            }
        }

        $this->vars['db_primary_keys'] = implode(",\n", $fields);
    }
254656
protected static function define_properties() : array {
        return array(
                'fieldid'        => [
                        'type' => PARAM_INT,
                        'optional' => false,
                        'null'     => NULL_NOT_ALLOWED
                ],
                'instanceid'       => [
                        'type' => PARAM_INT,
                        'optional' => false,
                        'null'     => NULL_NOT_ALLOWED
                ],
                'intvalue'       => [
                        'type'     => PARAM_INT,
                        'optional' => true,
                        'default'  => null,
                        'null'     => NULL_ALLOWED
                ],
                'decvalue'       => [
                        'type'     => PARAM_FLOAT,
                        'optional' => true,
                        'default'  => null,
                        'null'     => NULL_ALLOWED
                ],
                'charvalue'      => [
                        'type'     => PARAM_TEXT,
                        'optional' => true,
                        'default'  => null,
                        'null'     => NULL_ALLOWED
                ],
                'shortcharvalue' => [
                        'type'     => PARAM_TEXT,
                        'optional' => true,
                        'default'  => null,
                        'null'     => NULL_ALLOWED
                ],
                // Mandatory field.
                'value'          => [
                        'type'    => PARAM_RAW,
                        'null'    => NULL_NOT_ALLOWED,
                        'default' => ''
                ],
                // Mandatory field.
                'valueformat'    => [
                        'type'    => PARAM_INT,
                        'null'    => NULL_NOT_ALLOWED,
                        'default' => FORMAT_MOODLE,
                        'optional' => true
                ],
                'contextid'      => [
                        'type'     => PARAM_INT,
                        'optional' => false,
                        'null'     => NULL_NOT_ALLOWED
                ]
        );
    }
1322655
protected function _primaryKeyValue()
    {
        $fields = (array)$this->_table()->getPrimaryKey();
        $values = [];
        foreach ($fields as $field) {
            $values[] = $this->_deriveFieldFromContext($field);
        }

        if (count($values) === 1) {
            return $values[0];
        }

        return $values;
    }
1103740
public function getIds(): iterable
    {
        $this->checkRepository();

        $primaryKey  = $this->getClassMetadata()->getSingleIdentifierFieldName();

        $result = $this->_em
            ->createQueryBuilder()
            ->select('entity.'.$primaryKey)
            ->from($this->_entityName, 'entity')
            ->getQuery()
            ->getResult(Query::HYDRATE_ARRAY)
        ;

        $array = [];

        foreach ($result as $id) {
            $array[] = $id[$primaryKey];
        }

        return $array;
    }
652445
protected function getForeignKeyRelations() {
    if ($this->fkRelations == null) {
      $this->fkRelations = [];
      $relationDescs = $this->getRelations();
      foreach($relationDescs as $relationDesc) {
        if ($relationDesc instanceof RDBManyToOneRelationDescription) {
          $this->fkRelations[] = $relationDesc;
        }
      }
    }
    return $this->fkRelations;
  }
160215
public function getForeignPrimaryKeys()
    {
        $lfmap = $this->getLocalForeignMapping();
        $foreignTable = $this->getForeignTable();

        $foreignPKCols = [];
        foreach ($foreignTable->getPrimaryKey() as $fPKCol) {
            $foreignPKCols[$fPKCol->getName()] = true;
        }

        $foreignCols = [];
        foreach ($this->getLocalColumn() as $colName) {
            if ($foreignPKCols[$lfmap[$colName]]) {
                $foreignCols[] = $foreignTable->getColumn($lfmap[$colName]);
            }
        }

        return $foreignCols;
    }