Nette\Database\Table\Selection::getReferencingTable PHP Метод

getReferencingTable() публичный Метод

Returns referencing rows.
public getReferencingTable ( $table, $column, $active = NULL ) : GroupedSelection
Результат GroupedSelection
    public function getReferencingTable($table, $column, $active = NULL)
    {
        if (strpos($table, '.') !== FALSE) {
            list($table, $column) = explode('.', $table);
        } elseif (!$column) {
            $hasMany = $this->conventions->getHasManyReference($this->name, $table);
            if (!$hasMany) {
                return FALSE;
            }
            list($table, $column) = $hasMany;
        }
        $prototype =& $this->refCache['referencingPrototype'][$this->getSpecificCacheKey()]["{$table}.{$column}"];
        if (!$prototype) {
            $prototype = $this->createGroupedSelectionInstance($table, $column);
            $prototype->where("{$table}.{$column}", array_keys((array) $this->rows));
        }
        $clone = clone $prototype;
        $clone->setActive($active);
        return $clone;
    }

Usage Example

Пример #1
0
 /**
  * Returns referencing rows.
  * @param  string
  * @param  string
  * @return GroupedSelection
  */
 public function related($key, $throughColumn = NULL)
 {
     if (strpos($key, '.') !== FALSE) {
         list($key, $throughColumn) = explode('.', $key);
     }
     list($table, $column) = $this->table->getConnection()->getDatabaseReflection()->getHasManyReference($this->table->getName(), $key);
     return $this->table->getReferencingTable($table, $throughColumn ?: $column, $this[$this->table->getPrimary()]);
 }
All Usage Examples Of Nette\Database\Table\Selection::getReferencingTable