CodeIgniter Forums
Need help on converting mysql query to codeigniter active record - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: CodeIgniter 3.x (https://forum.codeigniter.com/forumdisplay.php?fid=17)
+--- Thread: Need help on converting mysql query to codeigniter active record (/showthread.php?tid=79049)



Need help on converting mysql query to codeigniter active record - jollytsr - 04-13-2021

Code:
SELECT date(`timestamp`)
     , COUNT(`odr_id`) AS num_sales
     , SUM(`amnt_paid`) AS daily_total
     , SUM(gov_fee) as e_pay
     , SUM(items_total) as sum_tot_cost
  FROM item_table
GROUP
    BY date(`timestamp`)
where ('user', $this->session->userdata('usernm'));

I get the username as table column and throws error saying "column not found"



RE: Need help on converting mysql query to codeigniter active record - php_rocs - 04-13-2021

@jollytsr,

Have you tried running this query directly in MySQL and seeing if it works correctly?


RE: Need help on converting mysql query to codeigniter active record - jollytsr - 04-14-2021

(04-13-2021, 06:54 AM)php_rocs Wrote: @jollytsr,

Have you tried running this query directly in MySQL and seeing if it works correctly?

@php_rocs

Thanks for your kind reply.

I have tried in mysql. It works perfectly. But unable to use it in codeIgniter.


RE: Need help on converting mysql query to codeigniter active record - php_rocs - 04-15-2021

@ jollytsr,

Can we see the code how you have it exactly in CI (line for line)?


RE: Need help on converting mysql query to codeigniter active record - kleber - 04-19-2021

(04-15-2021, 07:25 AM)php_rocs Wrote: @ jollytsr,

Can we see the code how you have it exactly in CI (line for line)?

Hello, send the way you set up the query using codeigniter(https://www.codeigniter.com/userguide3/database/query_builder.html).