Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to combine JSON result
    primarykey
    data
    text
    <p>Ho can i combine this result of JSON?</p> <p>The issue is that on try to combine this result on codeigniter i get an error Fatal error on Call to a member result_array() </p> <pre><code>$this-&gt;alerts -&gt;select('products.id as productid, products.code as code, products.name, products.price, sum(purchase_items.quantity)') -&gt;from('products'); $this-&gt;alerts-&gt;join('purchase_items', 'products.id = purchase_items.product_id'); $this-&gt;alerts-&gt;group_by("products.id"); echo "Total Purchases"; echo $this-&gt;alerts-&gt;generate(); $this-&gt;alerts -&gt;select('products.id as productid, products.code as code, products.name, products.price, sum(sale_items.quantity)') -&gt;from('products'); $this-&gt;alerts-&gt;join('sale_items', 'products.id = sale_items.product_id'); $this-&gt;alerts-&gt;group_by("products.id"); echo "Total Sales"; echo $this-&gt;alerts-&gt;generate(); </code></pre> <p>Result in JSON:</p> <pre><code>{"sEcho":0,"iTotalRecords":210,"iTotalDisplayRecords":210,"aaData":[["522","E12345","BAMBOO SCARF","100.00","3"]],"sColumns":"productid,code,products.name,products.price,sum(sale_items.quantity)"} {"sEcho":0,"iTotalRecords":210,"iTotalDisplayRecords":210,"aaData":[["522","E12345","BAMBOO SCARF","100.00","15"]],"sColumns":"productid,code,products.name,products.price,sum(sale_items.quantity),productid,code,products.name,products.price,sum(purchase_items.quantity)"} </code></pre> <p>Script to get the data from json:</p> <pre><code>$(document).ready(function() { $('#fileData').dataTable( { "aLengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]], "sPaginationType": "full_numbers", "aaSorting": [[ 0, "desc" ]], "bJQueryUI": true, "sDom": '&lt;"H"frlT&gt;&lt;"clear"&gt;t&lt;"clear"&gt;&lt;"F"ip&gt;', //&lt;"H"T&gt;&lt;"clear"&gt; //"sDom": '&lt;"top"i&gt;rt&lt;"bottom"flp&gt;&lt;"clear"&gt;', 'bProcessing' : true, 'bServerSide' : true, 'sAjaxSource' : 'index.php?getdata', 'fnServerData': function(sSource, aoData, fnCallback) { $.ajax ({ 'dataType': 'json', 'type' : 'POST', 'url' : sSource, 'data' : aoData, 'success' : fnCallback }); }, "oLanguage": { "sSearch": "Filter: " }, "aoColumns": [ null, null, null, null, null, { "bSortable": false } ] } ); } ); </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
    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