/** * Gets the entity with the smallest value for the specified field * @param string $field the name of the field for which you want the min value * @param int $type type_id (or blank for default) * @return entity entity with min value of field */ function get_min($field, $type = false) { if (!$type) { if ($this->type[0]) { $type = $this->type[0]; } else { return false; } } $m = new entity_selector($this->site_id); $m->swallow($this); $m->set_order($field . ' ASC'); $m->set_num(1); $item = $m->run_one($type, 'Live', "error selecting min"); if (!$item) { return false; } $current = end($item); return $current; }