So I have an area where people can write their own query against my database, but I want to limit the returned results (much like PhpMyAdmin).
So I need to check $_POST['query'] to see if has a limit statement, if it does, make sure it’s under 30, say. If there is no limit, I need to add it.
How would I do this?
You can use
preg_*functions to check the query and inject your preferred limit.EDIT: I totally ignored possible uses of the
LIMITkeyword. Here’s the edited version.will output
SELECT * FROM aa LIMIT 20,20