예제 #1
0
파일: Dt.php 프로젝트: tokushima/rhaco3
 private function filter_find($class, $order)
 {
     $object_list = array();
     $paginator = new \org\rhaco\Paginator(20, $this->in_vars('page', 1));
     $paginator->cp(array('order' => $order));
     if ($this->is_vars('search_clear')) {
         $object_list = $class::find_all($paginator, Q::select_order($order, $this->in_vars('porder')));
         $this->rm_vars();
     } else {
         if ($this->is_vars('search')) {
             $q = new \org\rhaco\store\db\Q();
             foreach ($this->ar_vars() as $k => $v) {
                 if ($v !== '' && strpos($k, 'search_') === 0) {
                     list(, $type, $key) = explode('_', $k, 3);
                     switch ($type) {
                         case 'timestamp':
                         case 'date':
                             list($fromto, $key) = explode('_', $key);
                             $q->add($fromto == 'to' ? Q::lte($key, $v) : Q::gte($key, $v));
                             break;
                         default:
                             $q->add(Q::contains($key, $v));
                     }
                     $paginator->vars($k, $v);
                 }
                 $paginator->vars('search', true);
             }
             $object_list = $class::find_all($q, $paginator, Q::select_order($order, $this->in_vars('porder')));
             $this->rm_vars('q');
         } else {
             $object_list = $class::find_all(Q::match($this->in_vars('q')), $paginator, Q::select_order($order, $this->in_vars('porder')));
             $paginator->vars('q', $this->in_vars('q'));
         }
     }
     return array($object_list, $paginator);
 }
예제 #2
0
파일: find.php 프로젝트: tokushima/rhaco3
foreach (\test\model\Find::find(Q::neq("value1", "ccc"), new \org\rhaco\Paginator(1, 3), Q::order("-id")) as $obj) {
    eq(isset($r[$i]) ? $r[$i] : null, $obj->value1());
    $i++;
}
foreach (\test\model\Find::find(Q::neq("value1", "abc"), new \org\rhaco\Paginator(1, 3), Q::order("id")) as $obj) {
    eq("jkl", $obj->value1());
}
$i = 0;
$r = array("mno", "aaa");
foreach (\test\model\Find::find(Q::neq("value1", "ccc"), new \org\rhaco\Paginator(1, 2), Q::order("order,-id")) as $obj) {
    eq(isset($r[$i]) ? $r[$i] : null, $obj->value1());
    $i++;
}
$result = \test\model\Find::find_all(Q::match("AAA", Q::IGNORE));
eq(3, sizeof($result));
$result = \test\model\Find::find_all(Q::match("AA", Q::IGNORE));
eq(3, sizeof($result));
$result = \test\model\Find::find_all(Q::eq("value2", null));
eq(1, sizeof($result));
$result = \test\model\Find::find_all(Q::neq("value2", null));
eq(7, sizeof($result));
$result = \test\model\Find::find_all(Q::eq("updated", null));
eq(6, sizeof($result));
$result = \test\model\Find::find_all(Q::neq("updated", null));
eq(2, sizeof($result));
eq("2008/12/24 10:00:00", $result[0]->fm_updated());
$c = 0;
for ($i = 0; $i < 10; $i++) {
    $a = $b = array();
    foreach (\test\model\Find::find_all(Q::random_order()) as $o) {
        $a[] = $o->id();