Welcome Guest, Not a member yet? Register   Sign In
mssql pagination
#8

[eluser]mr.zeno[/eluser]
[quote author="Rav3soul" date="1185508771"]The "_limit" function didn't work, so I modified the "mssql_driver.php" file to make it work. Check my changes and you can use it to make a new release.
Basically, it's just to modify "system/database/drivers/mssql/mssql_driver.php"
to
Code:
function _limit($sql, $limit, $offset)
{
// Horrible solucion =)
//$i = $limit + $offset;
//return preg_replace('/(^\SELECT (DISTINCT)?)/i','\\1 TOP '.$i.' ', $sql);        
$cursorName = 'mi_cursor_'.md5(strtolower($sql));
$sql = "DECLARE ".$cursorName." CURSOR DYNAMIC READ_ONLY FOR
    ".$sql."
    OPEN ".$cursorName."
    DECLARE @CURSOR AS INT
    SELECT @CURSOR = CURSOR_HANDLE FROM  MASTER.DBO.SYSCURSORS
    WHERE CURSOR_NAME = '".$cursorName."'
    EXEC SP_CURSORFETCH @CURSOR, 32, ".($offset+1).", ".$limit."
    EXEC SP_CURSORCLOSE @CURSOR";
    return $sql;
}
Yeah, I know: "It's a Cursor!", but this method not use "ORDER BY". I find this method here :
http://www.elguille.info/colabora/NET200...Server.htm
And I just modify this to work whit CodeIgniter.
I use this, and I find this method "the better" Smile

I've been waiting for your comments.[/quote]


This works for me, why are alternatives given? (is there something bad about this method?)


Messages In This Thread
mssql pagination - by El Forum - 07-26-2007, 04:59 PM
mssql pagination - by El Forum - 09-24-2007, 03:44 PM
mssql pagination - by El Forum - 09-24-2007, 05:13 PM
mssql pagination - by El Forum - 09-24-2007, 07:23 PM
mssql pagination - by El Forum - 09-25-2007, 02:48 PM
mssql pagination - by El Forum - 09-29-2007, 02:23 PM
mssql pagination - by El Forum - 09-29-2007, 10:47 PM
mssql pagination - by El Forum - 08-20-2008, 06:38 AM
mssql pagination - by El Forum - 03-04-2011, 02:16 AM



Theme © iAndrew 2016 - Forum software by © MyBB