summaryrefslogtreecommitdiff
path: root/README.markdown
diff options
context:
space:
mode:
authorJamie Matthews <[email protected]>2010-02-26 21:08:06 +0000
committerJamie Matthews <[email protected]>2010-02-26 21:08:06 +0000
commitb3fe39d3a7da8c6d8759e9c668e1536bb3b1daf1 (patch)
treeb4baa477aa4f4e739f1f065a6d0684b2a0709f18 /README.markdown
parentd5df1bdbcb4c1c3645a138337a01e7699bd42f9a (diff)
Fixed multiple bugs in query building
* ORDER BY, LIMIT and OFFSET parameters cannot be bound to the query as the database surrounds them with quotes, formining invalid SQL. They are now simply concatenated to the SQL string. The documentation has been updated to mark these as "unsafe" and not suitable for use with unfiltered user input. * ORDER BY should come before LIMIT and OFFSET.
Diffstat (limited to 'README.markdown')
-rw-r--r--README.markdown6
1 files changed, 6 insertions, 0 deletions
diff --git a/README.markdown b/README.markdown
index 1f6ba17..0aefe23 100644
--- a/README.markdown
+++ b/README.markdown
@@ -55,6 +55,8 @@ Idiorm provides a [*fluent interface*](http://en.wikipedia.org/wiki/Fluent_inter
All Idiorm queries start with a call to the `for_table` static method on the ORM class. This tells the ORM which table to use when making the query. Method calls which are then strung together. Finally, the chain is finished by calling either `find_one()` or `find_many()`, which executes the query and returns the result.
+*Note that this method **does not** escape its query parameter and so the table name should **not** be passed directly from user input.*
+
Let's start with a simple example. Say we have a table called `person` which contains the columns `id` (the primary key of the record - Idiorm assumes the primary key column is called `id` but this is configurable, see below), `name`, `age` and `gender`.
#### Single records ####
@@ -107,12 +109,16 @@ Note that this method only supports "question mark placeholder" syntax, and NOT
#### LIMIT and OFFSET ####
+*Note that these methods **do not** escape their query parameters and so these should **not** be passed directly from user input.*
+
The `limit` and `offset` methods map pretty closely to their SQL equivalents.
$people = ORM::for_table('person')->where('gender', 'female')->limit(5)->offset(10)->find_many();
#### ORDER BY ####
+*Note that this method **does not** escape its query parameter and so this should **not** be passed directly from user input.*
+
Two methods are provided to add `ORDER BY` clauses to your query. These are `order_by_desc` and `order_by_asc`, each of which takes a column name to sort by.
$people = ORM::for_table('person')->order_by_asc('gender')->order_by_desc('name')->find_many();