Re: [SMARTY] MS SQL & Pagination
| From: | Owen Cole | Date: | Thu, 07 Dec 2006 18:18:49 +0000 |
| Subject: | Re: [SMARTY] MS SQL & Pagination | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-13635@lists.php.net to get a copy of this message | ||
I wrote a little method for use with SmartyPaginate, SmartyColumnSort and MSSQL... I haven't used it in a while since I am trying to stay away from MS and you'll need to edit the variables to match your setup.. Hope this gives you some ideas though :)
*Notes:*
$smarty->PaginateTop = SmartyPaginate::getCurrentIndex($this->PaginateID);
$smarty->PaginateBottom = SmartyPaginate::getLimit($this->PaginateID);
$smarty->PaginateOrder = $columnsort->sortOrder(FALSE, $this->PaginateID);
$smarty->PaginateSortCol = explode(' ', $this->PaginateOrder);
/**
* Keep these in case it ever needs to be used for SQL Server database,
* mySQL is much better anyway but who knows
* @todo This needs to be fixed up a bit to actually be useable.. not a huge priority though...
*/
function PaginateMSSQL($sqlin) {
global $smarty;
if (isset($smarty->PaginateSortCol)) {
if ($smarty->PaginateSortCol[1] == "ASC") {
$sort2=" DESC";
} else {
$sort2=" ASC";
}
}
$sqltop = "SELECT * FROM (SELECT TOP ".$smarty->PaginateBottom." * FROM (SELECT TOP ".$smarty->PaginateTop." * FROM (";
$sqlbot = ") AS DATA1 ORDER BY ".$smarty->PaginateOrder.") AS DATA2 ORDER BY ".$sortcol[0].$sort2.") AS DATA3 ORDER BY ".$smarty->PaginateOrder;
return $sqltop.$sqlin.$sqlbot;} Donald Organ wrote:
Does anyone know of any plugins to handle pagination with smarty and ms sql?