Skip to content

Instantly share code, notes, and snippets.

@samsoir
Created January 29, 2009 14:56
Show Gist options
  • Save samsoir/54567 to your computer and use it in GitHub Desktop.
Save samsoir/54567 to your computer and use it in GitHub Desktop.
<?php
protected function get_stocks()
{
// Get the arguments supplied to this function
$args = func_get_args();
// Get the options supplied
$include_disabled = (bool) in_array('disabled', $args);
$include_empty = (bool) in_array('empty', $args);
if (isset($this->parent_id))
$where = array('currency_id' => $this->parent_id);
else
$where = array('currency_id' => $this->id);
if ( ! $include_disabled)
$where += array('disable_stock' => 1);
if ( ! $include_empty)
$where += array('stock_inventory >' => 0);
$stocks = ORM::factory('currency_stocks')
->where($where)
->orderby('buy_gbp_rate', 'ASC')
->find_all();
return $stocks;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment