/** * Returns a one-to-many relation as a HasManyList * * @param string $componentName Name of the component * @param string $filter A filter to be inserted into the WHERE clause * @param string|array $sort A sort expression to be inserted into the ORDER BY clause. If omitted, the static field $default_sort on the component class will be used. * @param string $join A single join clause. This can be used for filtering, only 1 instance of each DataObject will be returned. * @param string|array $limit A limit expression to be inserted into the LIMIT clause * * @return HasManyList The components of the one-to-many relationship. */ public function getComponents($componentName, $filter = "", $sort = "", $join = "", $limit = null) { $result = null; if(!$componentClass = $this->has_many($componentName)) { user_error("DataObject::getComponents(): Unknown 1-to-many component '$componentName' on class '$this->class'", E_USER_ERROR); } $joinField = $this->getRemoteJoinField($componentName, 'has_many'); $result = new HasManyList($componentClass, $joinField); if($this->model) $result->setModel($this->model); $result->setForeignID($this->ID); $result = $result->where($filter)->limit($limit)->sort($sort); if($join) $result = $result->join($join); return $result; }