summaryrefslogtreecommitdiff
path: root/docs/querying.rst
diff options
context:
space:
mode:
Diffstat (limited to 'docs/querying.rst')
-rw-r--r--docs/querying.rst32
1 files changed, 32 insertions, 0 deletions
diff --git a/docs/querying.rst b/docs/querying.rst
index 1e5afd3..a460a6a 100644
--- a/docs/querying.rst
+++ b/docs/querying.rst
@@ -27,6 +27,38 @@ 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``.
+A note on PSR-1 and camelCase
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+All the methods detailed in the documentation can also be called in a PSR-1 way:
+underscores (_) become camelCase. Here follows an example of one query chain
+being converted to a PSR-1 compliant style.
+
+.. code-block:: php
+
+ <?php
+ // documented and default style
+ $person = ORM::for_table('person')->where('name', 'Fred Bloggs')->find_one();
+
+ // PSR-1 compliant style
+ $person = ORM::forTable('person')->where('name', 'Fred Bloggs')->findOne();
+
+As you can see any method can be changed from the documented underscore (_) format
+to that of a camelCase method name.
+
+.. note::
+
+ In the background the PSR-1 compliant style uses the `__call()` and
+ `__callStatic()` magic methods to map the camelCase method name you supply
+ to the original underscore method name. It then uses `call_user_func_array()`
+ to apply the arguments to the method. If this minimal overhead is too great
+ then you can simply revert to using the underscore methods to avoid it. In
+ general this will not be a bottle neck in any application however and should
+ be considered a micro-optimisation.
+
+ As `__callStatic()` was added in PHP 5.3.0 you will need at least that version
+ of PHP to use this feature in any meaningful way.
+
Single records
^^^^^^^^^^^^^^