Exemplo n.º 1
0
     if ($totalCount > 0) {
         $totalPages = ceil($totalCount / $limit);
     } else {
         $totalPages = 0;
     }
     $objs = array();
     $accesor = 'get' . $otherJoinField . 'Object';
     if ($joinobs != -1) {
         foreach ($joinobs as $join) {
             $objs[] = $join->{$accesor}();
         }
     } else {
         $objs = -1;
     }
 } else {
     $q = IQL::select($reqobj);
     if (strpos($field, '.') > 0) {
         $fields = explode('.', $field);
         $field = $fields[1];
     }
     addWhereClause($q, NULL, $field, $value, $searchOption);
     $objs = $q->start($start)->limit($limit)->orderBy(NULL, $sidx, $sord)->get();
     $q = IQL::count($reqobj);
     addWhereClause($q, NULL, $fields[1], $value, $searchOption);
     $totalCount = $q->get();
     if ($totalCount > 0) {
         $totalPages = ceil($totalCount / $limit);
     } else {
         $totalPages = 0;
     }
 }
Exemplo n.º 2
0
//TODO add checks
$reqobj = Request::getOrPost("object");
$field = Request::getOrPost("field");
$value = Request::getOrPost("value");
$expanded = Request::getOrPost("expanded");
//	print($reqobj);
//	print($field);
//	print($value);
$reqDao = $reqobj . "Dao";
$dao = new $reqDao();
$reqJsonBuilder = $reqobj . "JsonBuilder";
$builder = new $reqJsonBuilder();
if ($field == 'ALL' && $value == 'ALL') {
    $objs = $dao->getAll();
} else {
    $objs = IQL::select($reqobj)->where(NULL, $field, '=', $value)->get();
}
if ($objs != -1) {
    $objCount = count($objs);
    for ($i = 0; $i < $objCount; $i++) {
        if ($i > 0) {
            echo "\n";
        }
        $obj = $objs[$i];
        if ($expanded == '1') {
            echo $builder->toExpandedJson($obj);
        } else {
            echo $builder->toJson($obj);
        }
    }
}