lithium\data\model\Relationship::query()

public method

Generates query parameters for a related object (or objects) for the given object connected to it by this relationship.

Parameters

  • object $object

    The object to get the related data for.

Returns

object

Returns the object(s) for this relationship.

Source

	public function query($object) {
		$conditions = (array) $this->constraints();

		foreach ($this->key() as $from => $to) {
			if (empty($object->{$from})) {
				return;
			}

			$conditions[$to] = $object->{$from};

			if ($conditions[$to] instanceof Traversable) {
				$conditions[$to] = iterator_to_array($conditions[$to], false);
			}

			if (empty($conditions[$to])) {
				return;
			}
		}
		$fields = $this->fields();
		$fields = $fields === true ? null : $fields;
		return compact('conditions', 'fields');
	}