diff options
author | Andrey Andreev <narf@devilix.net> | 2015-07-23 13:03:26 +0200 |
---|---|---|
committer | Andrey Andreev <narf@devilix.net> | 2015-07-23 13:03:26 +0200 |
commit | 56d346794306cc286288e82532f1e589f559ea91 (patch) | |
tree | 274822196faf9668b715183f27f18b702157a494 /user_guide_src | |
parent | 834860f90a8da6b52f79d1662c254f75e6c3e21e (diff) |
[ci skip] Polish changes from PR #3990
Diffstat (limited to 'user_guide_src')
-rw-r--r-- | user_guide_src/source/database/results.rst | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/user_guide_src/source/database/results.rst b/user_guide_src/source/database/results.rst index 071d9718e..5f5fafd38 100644 --- a/user_guide_src/source/database/results.rst +++ b/user_guide_src/source/database/results.rst @@ -176,19 +176,21 @@ the returned value's type:: Custom Result Objects ********************* -You can have the results returned as an instance of a custom class instead of a stdClass or array, -as the ``result()`` and ``result_array()`` methods allow. This requires that the class is already -loaded into memory. The object will have all values returned from the database set as properties. -If these have been declared and are non-public then you should provide a ``__set()`` -method to allow them to be set. +You can have the results returned as an instance of a custom class instead +of a ``stdClass`` or array, as the ``result()`` and ``result_array()`` +methods allow. This requires that the class is already loaded into memory. +The object will have all values returned from the database set as properties. +If these have been declared and are non-public then you should provide a +``__set()`` method to allow them to be set. Example:: class User { - protected $id; - protected $email; - protected $username; + public $id; + public $email; + public $username; + protected $last_login; public function last_login($format) @@ -213,13 +215,14 @@ Example:: } } -In addition to the two methods listed below, the following methods also can take a class name -to return the results as: ``first_row()``, ``last_row()``, ``next_row()``, and ``previous_row()``. +In addition to the two methods listed below, the following methods also can +take a class name to return the results as: ``first_row()``, ``last_row()``, +``next_row()``, and ``previous_row()``. **custom_result_object()** -Returns the entire result set as an array of instances of the class requested. The only parameter -is the name of the class to instantiate. +Returns the entire result set as an array of instances of the class requested. +The only parameter is the name of the class to instantiate. Example:: @@ -236,8 +239,8 @@ Example:: **custom_row_object()** -Returns a single row from your query results. The first parameter is the row number of the results. -The second parameter is the class name to instantiate. +Returns a single row from your query results. The first parameter is the row +number of the results. The second parameter is the class name to instantiate. Example:: @@ -245,7 +248,7 @@ Example:: $row = $query->custom_row_object(0, 'User'); - if (is_object($row)) + if (isset($row)) { echo $row->email; // access attributes echo $row->last_login('Y-m-d'); // access class methods |