本文整理汇总了PHP中Doctrine_Table::getRelations方法的典型用法代码示例。如果您正苦于以下问题:PHP Doctrine_Table::getRelations方法的具体用法?PHP Doctrine_Table::getRelations怎么用?PHP Doctrine_Table::getRelations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine_Table
的用法示例。
在下文中一共展示了Doctrine_Table::getRelations方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _getRelations
/**
* Returns all un-ignored relations
* @return array
*/
protected function _getRelations()
{
$relations = array();
foreach ($this->_table->getRelations() as $name => $definition) {
if (in_array($definition->getLocal(), $this->_ignoreColumns) || $this->_generateManyFields == false && $definition->getType() == Doctrine_Relation::MANY) {
continue;
}
$relations[$name] = $definition;
}
return $relations;
}
示例2: isForeignKey
/**
* Returns true if this column is a foreign key and false if it is not
*
* @return boolean $isForeignKey
*/
public function isForeignKey()
{
if (isset($this->foreignClassName)) {
return true;
}
if ($this->isPrimaryKey()) {
return false;
}
foreach ($this->table->getRelations() as $relation) {
if (strtolower($relation['local']) == strtolower($this->name)) {
$this->foreignClassName = $relation['class'];
return true;
}
}
return false;
}
示例3: getManyRelations
/**
* Return relations as an array
*
* Array must contain 'type' for relation type, 'id' for the name
* of the PK column of the related table, 'model' for the related class
* name, 'notnull' for nullability. 'local' for the name of the local column
* Key must be the alias of the relation column
*
* @return array
*/
public function getManyRelations()
{
$rels = $this->_table->getRelations();
$relations = array();
foreach ($rels as $rel) {
$relation = array();
if ($rel->getType() == Doctrine_Relation::MANY && isset($rel['refTable'])) {
$relation['id'] = $rel->getTable()->getIdentifier();
$relation['model'] = $rel->getClass();
$relation['local'] = $rel->getLocal();
$definition = $this->_table->getColumnDefinition($rel->getLocal());
$relation['notnull'] = isset($definition['notnull']) ? $definition['notnull'] : false;
$relations[$rel->getAlias()] = $relation;
}
}
return $relations;
}
示例4: isForeignKey
/**
* Returns true if this column is a foreign key and false if it is not
*
* @return boolean $isForeignKey
*/
public function isForeignKey()
{
if (isset($this->foreignClassName)) {
return true;
}
if ($this->isPrimaryKey()) {
return false;
}
foreach ($this->table->getRelations() as $relation) {
$local = (array) $relation['local'];
$local = array_map('strtolower', $local);
if (in_array(strtolower($this->name), $local)) {
$this->foreignClassName = $relation['class'];
return true;
}
}
return false;
}
示例5: buildIntegrityRelations
/**
* buildIntegrityRelations
*
* @param Doctrine_Table $table
* @param mixed $aliases
* @param mixed $fields
* @param mixed $indexes
* @param mixed $components
* @return void
*/
public function buildIntegrityRelations(Doctrine_Table $table, &$aliases, &$fields, &$indexes, &$components)
{
$deleteActions = Doctrine_Manager::getInstance()
->getDeleteActions($table->getComponentName());
foreach ($table->getRelations() as $relation) {
$componentName = $relation->getTable()->getComponentName();
if (in_array($componentName, $components)) {
continue;
}
$components[] = $componentName;
$alias = strtolower(substr($relation->getAlias(), 0, 1));
if ( ! isset($indexes[$alias])) {
$indexes[$alias] = 1;
}
if (isset($deleteActions[$componentName])) {
if (isset($aliases[$alias])) {
$alias = $alias . ++$indexes[$alias];
}
$aliases[$alias] = $relation->getAlias();
if ($deleteActions[$componentName] === 'SET NULL') {
if ($relation instanceof Doctrine_Relation_ForeignKey) {
foreach ((array) $relation->getForeign() as $foreign) {
$fields .= ', ' . $alias . '.' . $foreign;
}
} elseif ($relation instanceof Doctrine_Relation_LocalKey) {
foreach ((array) $relation->getLocal() as $foreign) {
$fields .= ', ' . $alias . '.' . $foreign;
}
}
}
foreach ((array) $relation->getTable()->getIdentifier() as $id) {
$fields .= ', ' . $alias . '.' . $id;
}
if ($deleteActions[$componentName] === 'CASCADE') {
$this->buildIntegrityRelations($relation->getTable(), $aliases, $fields, $indexes, $components);
}
}
}
}
示例6: listColumns
/**
* Provides a array of columns
*
* @param Doctrine_Table $table The current Doctrine_Table
*
* @return array
*/
private function listColumns(Doctrine_Table $table)
{
$ret = array();
foreach ($table->getColumns() as $name => $column) {
if (empty($column['primary'])) {
$added = true;
foreach ($table->getRelations() as $relation) {
if ($relation instanceof Doctrine_Relation_LocalKey && $relation->getLocal() === $name) {
$added = false;
break;
}
}
if ($added) {
$ret[] = sprintf("%s (%s)", $name, $column['type']);
}
}
}
return $ret;
}