Exemplo n.º 1
0
	/**
	 * Returns referencing rows.
	 * @param  string
	 * @param  string
	 * @return NGroupedTableSelection
	 */
	public function related($key, $throughColumn = NULL)
	{
		if (strpos($key, '.') !== FALSE) {
			list($key, $throughColumn) = explode('.', $key);
		} elseif (!$throughColumn) {
			list($key, $throughColumn) = $this->table->getConnection()->getDatabaseReflection()->getHasManyReference($this->table->getName(), $key);
		}

		return $this->table->getReferencingTable($key, $throughColumn, $this[$this->table->getPrimary()]);
	}
Exemplo n.º 2
0
	/**
	 * Returns referencing rows.
	 * @param  string
	 * @param  string
	 * @return NGroupedTableSelection
	 */
	public function related($key, $throughColumn = NULL)
	{
		if (strpos($key, '.') !== FALSE) {
			list($key, $throughColumn) = explode('.', $key);
		}

		list($table, $column) = $this->table->connection->databaseReflection->getHasManyReference($this->table->name, $key);
		$column = ($tmp=$throughColumn) ? $tmp : $column;
		$referencing = $this->table->getReferencingTable($table, $column);
		$referencing->active = $this[$this->table->primary];
		return $referencing;
	}