PDO icon indicating copy to clipboard operation
PDO copied to clipboard

Limit clause with sql server

Open johnlackey opened this issue 9 years ago • 6 comments

Can we detect driver and change LIMIT 1 to TOP(1) and place after SELECT?

johnlackey avatar Mar 03 '16 14:03 johnlackey

Might be something to look into for V2. :+1:

FaaPz avatar Mar 03 '16 15:03 FaaPz

I maybe able to contribute one here soon.

kwhat avatar Mar 04 '16 05:03 kwhat

Ok, now that 2.x stuff is just about done, I am going to shoot for this around version 3.x. @johnlackey If its still a desire, you can extend v2 to override the __toString() rendering. You will need to extend the database class as well if you want to use it as a factory.

kwhat avatar Sep 20 '19 22:09 kwhat

@johnlackey Do you know what the support for TOP limit is in sql server? I seem to remember there being a syntax change in 2012. The old code I was using looked something like OFFSET {$this->offset} ROWS FETCH NEXT {$this->number} ROWS ONLY but I think that was only for 2012 and later.

kwhat avatar Dec 16 '19 01:12 kwhat

TOP is supported for 2005 and above

johnlackey avatar Dec 16 '19 18:12 johnlackey

@johnlackey https://github.com/kwhat/PDO-SqlSrv Give this a go. It will only work with what I will be pushing to the 2.1 branch.

kwhat avatar Dec 17 '19 08:12 kwhat