Note that there are some explanatory texts on larger screens.

plurals
  1. POFiguring out how to output data the right way for a chart to work
    text
    copied!<p>I've been trying to figure out a way to get data from my database, and then display it in a way that a a chart can read it. </p> <p>Controller: $this->Record->virtualFields['sum'] ='COUNT(*)';</p> <pre><code> $records=$this-&gt;Record-&gt;find('list', array('fields' =&gt; array('drug_id', 'sum'), // from the table 'drugs' with 2 fields which drug_id and drug 'group' =&gt; 'drug_id')); debug($records); $chartData[] = implode(', ',$records); debug($chartData); </code></pre> <p>How my 'debugs' display on the page:</p> <pre><code>/app/Controller/RecordsController.php (line 72) array( 'Trees' =&gt; '2', 'Socks' =&gt; '1', 'Things' =&gt; '9', 'Mice' =&gt; '1', 'Clothes' =&gt; '6', 'Shoes' =&gt; '4', 'Underwear' =&gt; '3', 'Tables' =&gt; '6', 'Mouse' =&gt; '1' ) /app/Controller/RecordsController.php (line 74) array( (int) 0 =&gt; '2, 1, 9, 1, 6, 4, 3, 6, 1' ) </code></pre> <p>As you can see, the impload, for some reason, removes the substance field. I need it to display like this:</p> <pre><code>'Underwear', '1' etc </code></pre> <p>EDIT:</p> <p>How would I use hasMany to assign the compound an id with the database. Because the same compound will have many different users. And many different compounds will have the same users. </p> <p>I'm reading the documentation, but I don't know if i'm missing something but it seems like it just randomly cuts out on the documentation... it seems like it just tells you what it does and how to start it. </p> <p>If I were to run the query right now (i edited the query above for this example) I will get values with </p> <pre><code>'5' =&gt; '2' </code></pre> <p>But I would need to, I assume, use hasMany to associate what will be in my database </p> <pre><code>ID | Compound 5 | Tables </code></pre> <p>So that I can display 'tables' instead of 5</p>
 

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