Skip to content

Commit

Permalink
Added info for the to_array() method
Browse files Browse the repository at this point in the history
  • Loading branch information
Derrick Egersdorfer committed Jul 19, 2016
1 parent 34b2532 commit bfdf33e
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/orm/crud.html
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,22 @@ <h3 id="find_chaining">Find using method chaining</h3>
<p>All these methods are equally valid, the four other methods of find actually use the Query object as
well but don't return it.</p>

<h3 id="partial_selects">Converting to an array</h3>
<p>You can convert a single query result to an array using the to_array() method
</p>

<pre class="php"><code>
// using the chaining method. select one row and convert it to an array
$entry = Model_Article::query()->where('id', '=', 8)->get_one()->to_array();

// select one row, convert it to an array, include custom data and also run recursivly
$entry = Model_Article::query()->where('id', '=', 8)->get_one()->to_array(true, true);

// select one row and convert it to an array, include custom data, run recursivly and get eav relations
$entry = Model_Article::query()->where('id', '=', 8)->get_one()->to_array(true, true, true);
</code></pre>


<h3 id="partial_selects">Partial column selects</h3>
<p>By default all ORM find methods will select all table columns. You can use the <kbd>select</kbd> array
entry or the <kbd>select()</kbd> method to alter this behavior.
Expand Down

0 comments on commit bfdf33e

Please sign in to comment.