summaryrefslogtreecommitdiff
path: root/README.markdown
diff options
context:
space:
mode:
Diffstat (limited to 'README.markdown')
-rw-r--r--README.markdown24
1 files changed, 20 insertions, 4 deletions
diff --git a/README.markdown b/README.markdown
index 2b31155..d148145 100644
--- a/README.markdown
+++ b/README.markdown
@@ -41,6 +41,12 @@ Changelog
* Fix bug in quoting column wildcard. j4mie/paris#12
* Small documentation improvements
+#### 1.2.0 - release 2012-XX-XX
+
+* Add `order_by_expr` method [sandermarechal]
+* Add support for raw queries without parameters argument [sandermarechal]
+* Add support to set multiple properties at once by passing an associative to `set` method [sandermarechal]
+
Philosophy
----------
@@ -202,12 +208,16 @@ The `limit` and `offset` methods map pretty closely to their SQL equivalents.
##### Ordering #####
-*Note that this method **does not** escape its query parameter and so this should **not** be passed directly from user input.*
+*Note that these methods **do not** escape their query parameters and so these 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.
+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. The column names will be quoted.
$people = ORM::for_table('person')->order_by_asc('gender')->order_by_desc('name')->find_many();
+If you want to order by something other than a column name, then use the `order_by_expr` method to add an unquoted SQL expression as an `ORDER BY` clause.
+
+ $people = ORM::for_table('person')->order_by_expr('SOUNDEX(`name`)')->find_many();
+
#### Grouping ####
*Note that this method **does not** escape it query parameter and so this should **not** by passed directly from user input.*
@@ -297,7 +307,7 @@ The `join` methods also take an optional third parameter, which is an `alias` fo
#### Raw queries ####
-If you need to perform more complex queries, you can completely specify the query to execute by using the `raw_query` method. This method takes a string and an array of parameters. The string should contain placeholders, either in question mark or named placeholder syntax, which will be used to bind the parameters to the query.
+If you need to perform more complex queries, you can completely specify the query to execute by using the `raw_query` method. This method takes a string and optionally an array of parameters. The string can contain placeholders, either in question mark or named placeholder syntax, which will be used to bind the parameters to the query.
$people = ORM::for_table('person')->raw_query('SELECT p.* FROM person p JOIN role r ON p.role_id = r.id WHERE r.name = :role', array('role' => 'janitor')->find_many();
@@ -333,7 +343,7 @@ The `as_array` method takes column names as optional arguments. If one or more o
### Updating records ###
-To update the database, change one or more of the properties of the object, then call the `save` method to commit the changes to the database. Again, you can change the values of the object's properties either by using the `set` method or by setting the value of the property directly:
+To update the database, change one or more of the properties of the object, then call the `save` method to commit the changes to the database. Again, you can change the values of the object's properties either by using the `set` method or by setting the value of the property directly. By using the `set` method it is also possible to update multiple properties at once, by passing in an associative array:
$person = ORM::for_table('person')->find_one(5);
@@ -341,6 +351,12 @@ To update the database, change one or more of the properties of the object, then
$person->set('name', 'Bob Smith');
$person->age = 20;
+ // This is equivalent to the above two assignments
+ $person->set(array(
+ 'name' => 'Bob Smith',
+ 'age' => 20
+ ));
+
// Syncronise the object with the database
$person->save();