Welcome Guest, Not a member yet? Register   Sign In
Active Record: COUNT WHERE?
#11

[eluser]OliverHR[/eluser]
This thread is not getting old, is old :lol:.

But I still have a comment to make.

What about this query:

Code:
function product_detail($customer, $session, $product_id)
    {
        $this->db->select('products.reference');
        $this->db->select_sum('price', 'total'); //by the way in the user guide
                                                 //documentation is incomplete.

        // I Would prefer a function at codeigniter's style!!!!
        $this->db->select('Count(product_id) AS quantity');


        $this->db->join('products', 'products.id = temp_order.product_id');
        // Repetitive, but very simple and clear(to me and the next one...)
        $this->db->where('customer_id', $customer);
        $this->db->where('cart_session', $session);
        $this->db->where('product_id', $product_id);

        $this->db->group_by('products.reference');

        $query = $this->db->get('temp_order');

        return $query->row_array();
    }

It would be easier if CI provide us a function like:
Code:
select_count($select = '', $alias = '')


Messages In This Thread
Active Record: COUNT WHERE? - by El Forum - 09-04-2007, 10:36 PM
Active Record: COUNT WHERE? - by El Forum - 09-05-2007, 12:00 AM
Active Record: COUNT WHERE? - by El Forum - 09-05-2007, 12:50 AM
Active Record: COUNT WHERE? - by El Forum - 09-05-2007, 06:43 AM
Active Record: COUNT WHERE? - by El Forum - 09-20-2007, 03:37 PM
Active Record: COUNT WHERE? - by El Forum - 09-20-2007, 03:51 PM
Active Record: COUNT WHERE? - by El Forum - 09-21-2007, 08:51 AM
Active Record: COUNT WHERE? - by El Forum - 09-21-2007, 05:07 PM
Active Record: COUNT WHERE? - by El Forum - 11-05-2007, 08:00 PM
Active Record: COUNT WHERE? - by El Forum - 12-18-2007, 08:50 AM
Active Record: COUNT WHERE? - by El Forum - 12-30-2008, 10:57 PM
Active Record: COUNT WHERE? - by El Forum - 05-21-2010, 11:47 PM
Active Record: COUNT WHERE? - by El Forum - 01-18-2012, 11:07 PM
Active Record: COUNT WHERE? - by El Forum - 03-03-2013, 09:21 PM



Theme © iAndrew 2016 - Forum software by © MyBB