Welcome Guest, Not a member yet? Register   Sign In
do I really need to make an array to get result from db?
#6

[eluser]Prophet[/eluser]
Code:
function getProducts()
{
    $query = $this->db->get('product');
    return $query->result();
}

$products = getProducts(); //$products now contains $query->result();

//In the same way that you used foreach ($query->result() as $row)...
foreach ($products as $product)
{
    echo "{$product->id} - {$product->name} - {$product->price}";
}

At the end of the day, if you're more comfortable using arrays than objects... Use arrays Smile


Messages In This Thread
do I really need to make an array to get result from db? - by El Forum - 07-25-2010, 02:29 PM



Theme © iAndrew 2016 - Forum software by © MyBB