Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Dibify sql LIMIT close - Should fix #592
Browse files Browse the repository at this point in the history
  • Loading branch information
cdujeu committed Aug 6, 2014
1 parent 797d757 commit a4467b3
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions core/src/plugins/conf.sql/class.sqlConfDriver.php
Expand Up @@ -271,7 +271,7 @@ public function listRepositoriesWithCriteria($criteria, &$count = null){
$wheres[] = array("[$cName] = $type", $cValue);
}
}else if($cName == "CURSOR"){
$limit = "LIMIT ".$cValue["OFFSET"].",".$cValue["LIMIT"];
$limit = $cValue;
}else if($cName == "ORDERBY"){
$order = "ORDER BY ".$cValue["KEY"]." ".$cValue["DIR"];
}else if($cName == "GROUPBY"){
Expand All @@ -284,7 +284,11 @@ public function listRepositoriesWithCriteria($criteria, &$count = null){
$count = $res->fetchSingle();
}

$res = dibi::query("SELECT * FROM [ajxp_repo] WHERE %and $groupBy $order $limit", $wheres);
if(!empty($limit) && is_array($limit)){
$res = dibi::query("SELECT * FROM [ajxp_repo] WHERE %and $groupBy $order %lmt %ofs", $wheres, $limit["LIMIT"], $limit["OFFSET"]);
}else{
$res = dibi::query("SELECT * FROM [ajxp_repo] WHERE %and $groupBy $order", $wheres);
}
$all = $res->fetchAll();
return $this->initRepoArrayFromDbFetch($all);

Expand Down Expand Up @@ -834,10 +838,11 @@ public function simpleStoreList($storeId, $cursor=null, $dataIdLike="", $dataTyp
}
$limit = '';
if($cursor != null){
$limit = "LIMIT ".$cursor[0].','.$cursor[1];
}
$children_results = dibi::query("SELECT * FROM [ajxp_simple_store] WHERE %and %lmt %ofs", $wheres, $cursor[1], $cursor[0]);
}else{
$children_results = dibi::query("SELECT * FROM [ajxp_simple_store] WHERE %and", $wheres);

$children_results = dibi::query("SELECT * FROM [ajxp_simple_store] WHERE %and $limit", $wheres);
}
$values = $children_results->fetchAll();
$result = array();
foreach($values as $value){
Expand Down

0 comments on commit a4467b3

Please sign in to comment.