Re: [SMARTY] MS SQL & Pagination

Owen Cole <[email protected]> Thu, 07 Dec 2006 13:18:49 -0500
Newsgroups gmane.comp.php.smarty.general
Organization Total Sales & Marketing
Message-ID <[email protected]>
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?
>

-- 
Smarty General Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php