Comments (5)
Hi,
Thanks for the patch - I need to do a bit of research into how portable this is, as hardcoding a value like that seems a bit odd...
Jamie
from idiorm.
Hi j4mie,
yes, it also looked a bit odd to me, but since there's no way in standard SQL to ommit LIMIT, when also OFFSET is given, specifiying a LIMIT of 2^64 -1 == 18446744073709551615 (e.g. max value for an unsigned 64-bit integer, ULLONG_MAX from limits.h) seems to be the widely accepted solution (at least in MySQL - it is also shown in MySQL examples).
Postgres, however supports a LIMIT ALL.
Edit: Just checked the PHP docs; there does not seem to be a define for this value. Workaround:
define(ULLONG_MAX, '18446744073709551615');
from idiorm.
It's the portability that worries me. I can't add MySQL-only code to Idiorm, and adding "special cases" for every database is something I'm trying to avoid wherever possible
I'm actually struggling to see exactly why this is needed. Can't you just ensure that limit()
is always called when offset()
is called in your code? It feels like magically adding a limit to a query would be non-intuitive and surprising to a user.
from idiorm.
Hi j4mie,
actually, I agree with your concerns about portability. I can of course ensure, that I'll use limit()
always, whenever I also use offset()
.
Apart from this LIMIT/OFFSET
is supported by Postgres, MySQL and SQLite only (as far as I can tell - and LIMIT
may be omitted only in Postgres). MSSQL / Oracle do not support it (yet) at all, so paging and limiting must be done there with other statements anyway. For the three mentioned, the above solution is fairly portable and commonly used (and you wouldn't have to distinguish between the underlying RDBMs).
Greetings
ViFo
from idiorm.
This should be controlled by the application and not at the ORM level in my opinion and I don't like having a hard coded value in the ORM like this.
from idiorm.
Related Issues (20)
- Is this project still maintained? HOT 2
- how to do arithmetic operator in idiorm ? HOT 3
- Offset support for MSSQL / SQLSRV
- Difference between raw_query and raw_execute HOT 1
- raw_join missing "JOIN" in Statement? HOT 3
- How do I connect to MSSQL? HOT 1
- config.php was changed as below with MySQL db thing HOT 4
- DOException Code: HY000 Message: SQLSTATE[HY000]: General error HOT 1
- Should Idiorm be marked as end of life? HOT 6
- Release 1.5.7 not on packagist HOT 3
- Issue when comparing using expressions HOT 2
- Question about safety HOT 3
- Multiple connections - instances HOT 4
- Save to update without query first HOT 6
- save() return value HOT 1
- Num Rows from Result? HOT 1
- Finding multiple records makes API Crash
- PHP 8.1 compatibility
- PHP8.1 compatibility issue on logging null
- need help please HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from idiorm.