property, the table alias is * given to be included with the property * * @param string * @return array */ public function select($table) { $props = call_user_func(array($this->model_to, 'properties')); $i = 0; $properties = array(); foreach ($props as $pk => $pv) { $properties[] = array($table.'.'.$pk, $table.'_c'.$i); $i++; } return $properties; } /** * Returns tables to join and fields to select with optional additional settings like order/where * * @param $alias_from * @param $rel_name * @param $alias_to * * @return array */ abstract public function join($alias_from, $rel_name, $alias_to); /** * Saves the current relationships and may cascade saving to model_to instances * * @param Model $model_from * @param Model $model_to * @param $original_model_id * @param $parent_saved * @param bool|null $cascade * @internal param \Orm\instance $Model of model_from * @internal param array|\Orm\Model $single or multiple model instances to save * @internal param \Orm\whether $bool the model_from has been saved already * @internal param bool|null $either uses default setting (null) or forces when true or prevents when false * * @return */ abstract public function save($model_from, $model_to, $original_model_id, $parent_saved, $cascade); /** * Takes the current relations and attempts to delete them when cascading is allowed or forced * * @param Model $model_from instance of model_from * @param array|Model $model_to single or multiple model instances to delete * @param bool $parent_deleted whether the model_from has been saved already * @param null|bool $cascade either uses default setting (null) or forces when true or prevents when false */ abstract public function delete($model_from, $model_to, $parent_deleted, $cascade); /** * Allow outside access to protected properties * * @param $property * @throws \FuelException Invalid relation property * @return */ public function __get($property) { if (strncmp($property, '_', 1) == 0 or ! property_exists($this, $property)) { throw new \FuelException('Invalid relation property: '.$property); } return $this->{$property}; } /** * Returns true if this relation is a singular relation. Eg, has_one not has_many * * @return bool */ public function is_singular() { return $this->singular; } }