Welcome Guest, Not a member yet? Register   Sign In
Help with Binding
#1

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.
Reply
#2

@Shamunda,
Here is the link to the user guide that will assist you. https://www.codeigniter.com/user_guide/d...eries.html
Reply
#3

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);
Reply
#4

(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.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB