Welcome Guest, Not a member yet? Register   Sign In
ActiveRecord Expert Needed!
#4

[eluser]davidbehler[/eluser]
Untested!
Code:
function get_many_products($num = 10)
        {
            $this->db->select('*');
            $this->db->from('product_list');
            $this->db->limit($num);
            $query = $this->db->get();
        
            if ( $query->num_rows() > 0 )
            {
                $product_list = $query->result_array();
                foreach($product_list as $key => $product)
                {
                  $this->db->from('productmeta');
                  $this->db->where('product_id', $product['id']);
                  $query = $this->db->get();
                  if($query->num_rows() > 0)
                  {
                    $product_list[$key]['meta_data'] = $query->result_array();
                  }
                  else
                  {
                    $product_list[$key]['meta_data'] = array();
                  }
                }
                return $product_list;
            }
            
            return array();
        }


Messages In This Thread
ActiveRecord Expert Needed! - by El Forum - 08-20-2009, 12:28 AM
ActiveRecord Expert Needed! - by El Forum - 08-20-2009, 01:11 AM
ActiveRecord Expert Needed! - by El Forum - 08-20-2009, 01:21 AM
ActiveRecord Expert Needed! - by El Forum - 08-20-2009, 01:33 AM
ActiveRecord Expert Needed! - by El Forum - 08-20-2009, 01:36 AM
ActiveRecord Expert Needed! - by El Forum - 08-20-2009, 01:39 AM
ActiveRecord Expert Needed! - by El Forum - 08-20-2009, 02:11 PM



Theme © iAndrew 2016 - Forum software by © MyBB