Question

Here is the code

$db = JFactory::getDBO();
$query = "SELECT order_id FROM orders WHERE customer_number = '".$i."' AND created_on = '".$date."'";
$db->setQuery($query);
$rows = $dbz->loadObjectList();
print_r($rows);

The output is Array ( [0] => stdClass Object ( [virtuemart_order_id] => 549 ) )

I want to get only 549 as output? What is the possible solution.

Note foreach() doesn't work for me.

Was it helpful?

Solution

try this :

    $rows[0]->virtuemart_order_id;

OTHER TIPS

You should probably use another function to load your data. Like:

$db = JFactory::getDBO();
$query = "SELECT order_id FROM orders WHERE customer_number = '".$i."' AND created_on = '".$date."'";
$db->setQuery($query);
$order_id = $dbz->loadResult();
echo $order_id; 

Check the joomla API documentation to find the right API-calls depending on what you need to do: http://api.joomla.org/cms-2.5/classes/JDatabase.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top