
Untitled
By: a guest on
May 14th, 2012 | syntax:
None | size: 0.59 KB | hits: 11 | expires: Never
class InventoryItem extends Zend_Db_Table_Row_Abstract
{
public function quantity($location = null)
{
$invMgr = new Inventory();
$select = $this->select()->setIntegrityCheck(false);
$select->from('Inventory', 'SUM(qty_onhand) AS qty')
->where('item_id = ?', $this->item_id, Zend_Db::INT_TYPE)
->group('item_id');
if ($location) {
$select->where('location_id = ?', $location, Zend_Db::INT_TYPE);
}
$res = $select->query(Zend_Db::FETCH_OBJ)->fetch();
return (int)$res->qty;
}
}
// transfers.php
$thing = new InventoryItem();
echo $thing->quantity(1);