/** * サブクエリを取得する * @param $name 対象のプロパティ * @return Daq */ public static function find_sub($name) { $args = func_get_args(); array_shift($args); $dao = new static(); $query = new \ebi\Q(); $query->add($dao->__find_conds__()); if (!empty($args)) { call_user_func_array([$query, 'add'], $args); } if (!$query->is_order_by()) { $query->order($name); } $paginator = $query->paginator(); if ($paginator instanceof \ebi\Paginator) { if ($query->is_order_by()) { $paginator->order($query->in_order_by(0)->ar_arg1(), $query->in_order_by(0)->type() == Q::ORDER_ASC); } else { if ($paginator->has_order()) { $query->add(Q::order($paginator->order())); } } $paginator->total(call_user_func_array([get_called_class(), 'find_count'], $args)); if ($paginator->total() == 0) { return []; } } return self::$_con_[get_called_class()]->select_sql($dao, $query, $paginator, $name); }