CodeIgniter Forums
Help with Binding - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Help with Binding (/showthread.php?tid=68902)



Help with Binding - Shamunda - 09-12-2017

I'm not familiar with CI but could someone provide me with a solution of how I would properly bind this query:

$ncCouponQuery = $this->db->query("select c.*,(select count(*) from coupon_analytics CA where CA.CouponID = c.ID ) as AdminCnt from coupon_master c group by c.ID");


Thank you.


RE: Help with Binding - php_rocs - 09-12-2017

@Shamunda,
Here is the link to the user guide that will assist you. https://www.codeigniter.com/user_guide/database/queries.html


RE: Help with Binding - ktmonty - 09-13-2017

Hope this work.
$ncCouponQuery = $this->db->select('*')
->from('coupon_master')
->group_by('coupon_master.ID')
->join('coupon_analytics','coupon_analytics.CouponID=coupon_master.ID')
->get()
->result();
$count= count($ncCouponQuery);


RE: Help with Binding - Shamunda - 09-13-2017

(09-13-2017, 03:11 AM)ktmonty Wrote: Hope this work.
$ncCouponQuery = $this->db->select('*')
->from('coupon_master')
->group_by('coupon_master.ID')
->join('coupon_analytics','coupon_analytics.CouponID=coupon_master.ID')
->get()
->result();
$count= count($ncCouponQuery);

Thank very much. This is basically what I was looking for so I can use this as a template to work with more complex queries. The guide shows basic examples.

Again, thank you.