Note that there are some explanatory texts on larger screens.

plurals
  1. POIn CakePhp, how can I retrieve only one column from my database?
    primarykey
    data
    text
    <p>I have a very simple application with 1 table, each row contains a word, it's definition, and an example.</p> <p>The definition and example fields are varchars(5000).</p> <p>On every page, I have a sidebar which displays the list of words. After a certain number of words I started getting the following error:</p> <pre><code>Error: Allowed memory size of 33554432 bytes exhausted </code></pre> <p>The code in the controller that sets the variable used in the Element:</p> <pre><code>$this-&gt;set('allWords', $this-&gt;Word-&gt;find('all', array('order' =&gt; array('Word.text ASC')))); </code></pre> <p>I suspect that the find method reads in all the row data, including the definition and example, which I really don't need at this moment, and this causes the error.</p> <p>Is there any way to just read the id and the word, and not the definition and example values for each row?</p> <p><strong>Update</strong></p> <p>Inside my Element I loop through the $allWords array to print out each word along with a link:</p> <pre><code>echo '&lt;h3&gt;Words ('.count($allWords).')&lt;/h3&gt;'; echo $this-&gt;Html-&gt;link('Add new', array('controller' =&gt; 'words', 'action' =&gt; 'add')); echo '&lt;br/&gt;&lt;br/&gt;'; foreach($allWords as $thisWord) { echo $this-&gt;Html-&gt;link($thisWord['Word']['text'], array('controller' =&gt; 'words', 'action' =&gt; 'edit', $thisWord['Word']['id'])); if( ($thisWord['Word']['example'] == '') || ($thisWord['Word']['definition'] == '') ) { echo '&amp;nbsp;' . $this-&gt;Html-&gt;image('warning.png'); } echo '&lt;br \&gt;'; } </code></pre> <p>It appears that if I comment out the inner part of the foreach loop, I don't get the memory error.</p> <p>The SQL output in this case is:</p> <pre><code>SELECT `Word`.`id` FROM `idioms`.`words` AS `Word` WHERE 1 = 1 ORDER BY `Word`.`text` ASC` </code></pre> <p>with 339 rows affected.</p> <p>Thanks!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload