summaryrefslogtreecommitdiff
path: root/README.markdown
diff options
context:
space:
mode:
Diffstat (limited to 'README.markdown')
-rw-r--r--README.markdown16
1 files changed, 16 insertions, 0 deletions
diff --git a/README.markdown b/README.markdown
index dcad3a4..4078f6a 100644
--- a/README.markdown
+++ b/README.markdown
@@ -25,6 +25,12 @@ Features
Changelog
---------
+#### 1.3.0 - release XXXX-XX-XX
+
+* Add in raw_execute - closes issue #40 [[tag](https://github.com/tag)]
+* Add query logging to `delete_many` [[tag](https://github.com/tag)]
+* Add `is_new` method - closes issue #85
+
#### 1.2.3 - release 2012-11-28
* Fix issue #78 - remove use of PHP 5.3 static call
@@ -401,6 +407,8 @@ The other functions (`AVG`, `MAX` and `SUM`) work in exactly the same manner. Su
#### Raw queries ####
+##### Return Idiorm instances #####
+
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();
@@ -409,6 +417,12 @@ The ORM class instance(s) returned will contain data for all the columns returne
Note that using `raw_query` is advanced and possibly dangerous, and Idiorm does not make any attempt to protect you from making errors when using this method. If you find yourself calling `raw_query` often, you may have misunderstood the purpose of using an ORM, or your application may be too complex for Idiorm. Consider using a more full-featured database abstraction system.
+##### Direct PDO access raw queries #####
+
+It is possible to skip Idiorm's query building system altogether by using `raw_execute`. You will not get an Idiorm instance as a result and it is also potentially dangerous just like the method above.
+
+ $people = ORM::raw_execute('INSERT OR REPLACE INTO `widget` (`id`, `name`) SELECT `id`, `name` FROM `other_table` WHERE id = ?', array(10));
+
### Getting data from objects ###
Once you've got a set of records (objects) back from a query, you can access properties on those objects (the values stored in the columns in its corresponding table) in two ways: by using the `get` method, or simply by accessing the property on the object directly:
@@ -479,6 +493,8 @@ To add a new record, you need to first create an "empty" object instance. You th
After the object has been saved, you can call its `id()` method to find the autogenerated primary key value that the database assigned to it.
+To determine if the instance you are operating on has been obtained by calling `create()` or whether it was via a query on the database you can call `is_new()` on it to get a boolean response.
+
#### Properties containing expressions ####
It is possible to set properties on the model that contain database expressions using the `set_expr` method.