Welcome Guest, Not a member yet? Register   Sign In
use foreach or single query? (Counting Inventory)
#4

[eluser]seanloving[/eluser]
[quote author="pete01" date="1264188945"]Try this:[/quote]

Now that I understand a couple more basics (thanks @pete01) I have this nice little function:

Code:
function get_inventory($location)
    {
        // for a given $location, return the product list showing product inventory levels
        return $this->CI->db
                        ->select('count(*) as qty,part_number,description,products.product_id')
                        ->from('inventory')
                        ->join('locations', 'locations.location_id=inventory.location_id')
                        ->where('location_name',$location)
                        ->join('products', 'products.product_id=inventory.product_id')
                        ->group_by('products.product_id')
                        ->get()->result_array();
    }


Messages In This Thread
use foreach or single query? (Counting Inventory) - by El Forum - 01-22-2010, 07:21 AM
use foreach or single query? (Counting Inventory) - by El Forum - 01-22-2010, 07:35 AM
use foreach or single query? (Counting Inventory) - by El Forum - 01-22-2010, 07:49 AM
use foreach or single query? (Counting Inventory) - by El Forum - 01-22-2010, 09:05 AM
use foreach or single query? (Counting Inventory) - by El Forum - 01-22-2010, 09:29 AM
use foreach or single query? (Counting Inventory) - by El Forum - 01-22-2010, 10:24 AM
use foreach or single query? (Counting Inventory) - by El Forum - 01-22-2010, 11:07 AM
use foreach or single query? (Counting Inventory) - by El Forum - 01-22-2010, 12:20 PM
use foreach or single query? (Counting Inventory) - by El Forum - 01-22-2010, 01:54 PM
use foreach or single query? (Counting Inventory) - by El Forum - 01-22-2010, 02:02 PM
use foreach or single query? (Counting Inventory) - by El Forum - 01-22-2010, 03:43 PM
use foreach or single query? (Counting Inventory) - by El Forum - 01-22-2010, 04:05 PM
use foreach or single query? (Counting Inventory) - by El Forum - 01-22-2010, 04:43 PM
use foreach or single query? (Counting Inventory) - by El Forum - 01-22-2010, 04:46 PM
use foreach or single query? (Counting Inventory) - by El Forum - 01-22-2010, 08:21 PM



Theme © iAndrew 2016 - Forum software by © MyBB