How can i change the
"getOne()"
"modifyLimitQuery()"
"getAll()"
in the code below to "normal" mysql query code? It is just this calling to the functions that needs to be changed to normal Mysql querys.
By the way, i use a MYSQL Abstraction Layer that i made. Thanks in Advance.
Here is the code that has to be changed:
$offset = intval($_REQUEST['offset']);
if (! $offset) { $offset = 1; }
$per_page = 5; //Links to display per page
$total = $db->getOne('SELECT COUNT * FROM zodiac');
$sql = $db->modifyLimitQuery('SELECT * FROM zodiac ORDER BY id',
$offset - 1,$per_page);
$ar = $db->getAll($sql);
foreach($ar as $k => $v) {
print "$v->sign, $v->symbol ($v->id)<br>";
}
pc_indexed_links($total,$offset,$per_page);
printf("<br>(Displaying %d - %d of %d)",$offset,$offset+$k,$total);
and here are the functions it calls:
//================================//
// Print Link Function //
//================================//
function pc_print_link($inactive,$text,$offset='') {
if ($inactive) {
printf('<font color="#666666">%s</font>',$text);
} else {
printf('<a href="%s?offset=%d">%s</a>',$_SERVER['PHP_SELF'],$offset,$text);
}
}
//================================//
// Print Page Navigation //
//================================//
function pc_indexed_links($total,$offset,$per_page) {
$separator = ' | ';
//print "<<Prev" link
pc_print_link($offset == 1, '<<Prev', $offset - $per_page);
//print all groupings except last one
for ($start = 1, $end = $per_page;
$end < $total;
$start += $per_page, $end += $per_page) {
print $separator;
pc_print_link($offset == $start, "$start-$end", $start);
}
/* print the last grouping -
* at this point, $start points to the element at the beginning
* of the last grouping
*/
/* the text should only contain a range if there's more than
* one element on the last page. For example, the last grouping
* of 11 elements with 5 per page should just say "11", not "11-11"
*/
$end = ($total > $start) ? "-$total" : '';
print $separator;
pc_print_link($offset == $start, "$start$end", $start);
// print "Next>>" link
print $separator;
pc_print_link($offset == $start, 'Next>>',$offset + $per_page);
}