Skip to content

Instantly share code, notes, and snippets.

@cofemei
Created September 27, 2012 02:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cofemei/3791754 to your computer and use it in GitHub Desktop.
Save cofemei/3791754 to your computer and use it in GitHub Desktop.
Oracle 分頁 test
// 分頁 test
$subsids = array('1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21');
$page = 10;
if (count($subsids) > $page) {
$totle = ceil(count($subsids) / $page);
$subsidIn = "";
for ($i=0; $i < $totle; $i++) {
$tmp = array();
$start = $i * $page;
$end = $start + $page;
if ($end > count($subsids)) {
$end = count($subsids);
}
for ($x=$start; $x < $end; $x++) {
$tmp[] = $subsids[$x];
}
$subsidIn .= " and a.subsid in (".join(',',$tmp).")";
}
} else {
$subsidIn = " and a.subsid in (".join(',',$subsids).")";
}
var_dump($subsidIn);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment