Check if this object has foreign keys that constraint it. Return TRUE in case of
existing constraints.

@return boolean
514017
public function isReferenced() {
		
		// return flag
		$exists = FALSE;
		
		// get list of references to check
		$references = $this->db->getInverseForeignKeys(static::TABLE_NAME);
		
		foreach ($references as $r) {
			
			// get object property name
			$property = array_search($r->REFERENCED_COLUMN_NAME, static::getBinds());
			
			// count for existing records that references
			$query =
				'SELECT COUNT(*)' .
				' FROM `' . $this->db->escape($r->TABLE_NAME) . '`' .
				' WHERE ' . $this->db->escape($r->COLUMN_NAME) . ' = ?';
			
			$this->db->setQuery($query);
			$count = $this->db->loadCount($this->$property);

			// set flag as true
			if ($count) $exists = TRUE;
			
		}
		
		return $exists;
		
	}
607404
public function hasPrimaryKey()
    {
        if ($this->autoIncrement) {
            $empty = true;

            foreach ($this->keys as $key) {
                $empty = $empty && !$this->$key;
            }

            return !$empty;
        }

        $conditions = [];

        foreach ($this->getKeyName(true) as $key) {
            $conditions[$key] = $this->$key;
        }

        return $this->getDataMapper()->find($conditions);
    }
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;
  }
674016
public function hasChildren()
    {
        $item = $this->data[$this->keys[$this->position]];

        return (is_object($item) && $item instanceof \Octris\Db\Type\SubObject);
    }
888077
public function addConstraints()
    {
        if (static::$constraints) {
            $foreignKey = $this->getForeignKeyName();
            $parentKeyValue = $this->getParentKey();

            //If the foreign key is an array (multi-column relationship), we adjust the query.
            if (is_array($this->foreignKey)) {
                foreach ($this->foreignKey as $index => $key) {
                    list(, $key) = explode('.', $key);
                    $fullKey = $this->getRelated()
                            ->getTable().'.'.$key;
                    $this->query->where($fullKey, '=', $parentKeyValue[$index]);
                    $this->query->whereNotNull($fullKey);
                }
            } else {
                $fullKey = $this->getRelated()
                        ->getTable().'.'.$foreignKey;
                $this->query->where($fullKey, '=', $parentKeyValue);
                $this->query->whereNotNull($fullKey);
            }
        }
    }
4445
public function getForeignKey()
    {
        if ($this->_foreignKey === null) {
            $this->_foreignKey = $this->_modelKey($this->getSource()->getTable());
        }

        return $this->_foreignKey;
    }
1081074
def table_has_constraint(table, name, db):
    """"""
    t = sa.Table(table, db.metadata, autoload=True, autoload_with=db.engine)

    for c in t.constraints:
        if c.name == name:
            return True
    return False
1220276
public function isLocalPrimaryKey()
    {
        $localCols = $this->getLocalColumns();

        $localPKColumnObjs = $this->getTable()->getPrimaryKey();

        $localPKCols = array();
        foreach ($localPKColumnObjs as $lPKCol) {
            $localPKCols[] = $lPKCol->getName();
        }

        return ((count($localPKCols) === count($localCols)) && !array_diff($localPKCols, $localCols));
    }
1027853
public function isLocalForeignKeyIgnored($foreignKey)
    {
        // do not create entities for many2many tables
        if ($this->getConfig()->get(FormatterInterface::CFG_SKIP_M2M_TABLES) && $foreignKey->getOwningTable()->isManyToMany()) {
            return true;
        }
        // do not output mapping in foreign table when the unidirectional option is set
        if ($foreignKey->parseComment('unidirectional') === 'true') {
            return true;
        }

        return false;
    }
1122898
public function checkMandatoryKey()
    {
        foreach ($this->mandatoryKeys as $key) {
            if (!array_key_exists($key, $this)) {
                return $key;
            }
        }

        return true;
    }
390533
private function isRelationForeignKeyNullable(Relation $relation)
    {
        $reflectionObj = new \ReflectionObject($relation);
        if (!$reflectionObj->hasProperty('foreignKey')) {
            return false;
        }
        $fkProp = $reflectionObj->getProperty('foreignKey');
        $fkProp->setAccessible(true);

        return isset($this->nullableColumns[$fkProp->getValue($relation)]);
    }
332507
@Override
	public boolean hasNextCase() {
		// this method only returns true if dependent values are grouped
		if (!dependent) {
			return false;
		}
		for (Constraint c : constraints) {
			if (c.hasNextCase()) {
				return true;
			}
		}
		return false;
	}
1222949
public function isAtLeastOneLocalPrimaryKeyIsRequired()
    {
        foreach ($this->getLocalPrimaryKeys() as $pk) {
            if ($pk->isNotNull() && !$pk->hasDefaultValue()) {
                return true;
            }
        }

        return false;
    }
942512
protected function getTableForeignKeys(): array
    {
        $data = [];

        $fks = $this->db->schema->getTableForeignKeys($this->tableName, true);

        /* @var $fk ForeignKeyConstraint */
        foreach ($fks as $fk) {
            $data[$fk->name] = new TableForeignKey([
                'name' => $fk->name,
                'columns' => $fk->columnNames,
                'refTable' => $fk->foreignTableName,
                'refColumns' => $fk->foreignColumnNames,
                'onDelete' => $fk->onDelete,
                'onUpdate' => $fk->onUpdate,
            ]);
        }

        return $data;
    }
182674
protected function getForeignKey()
	{
		if($this->foreignKey === null)
		{
			$this->foreignKey = $this->parent->getForeignKey();
		}

		return $this->foreignKey;
	}
105054
public function setForeignKeys( $keys )
	{
		$found = TRUE;
		$this->foreignKeys	= array();
		foreach( $keys as $key )
		{
			if( !in_array( $key, $this->foreignKeys ) )
				$this->foreignKeys[] = $key;
			else $found = FALSE;
		}
		return $found;
	}
801729
public function hasEnumColumns()
    {

        foreach ($this->getColumns() as $col) {
            if ($col->isEnumType() || $col->getValueSet()) {
                return true;
            }
        }

        return false;
    }