Welcome Guest, Not a member yet? Register   Sign In
Create a custom object from DB result()?
#6

[eluser]Matt S.[/eluser]
I see, I think the viable solution would be just to create private methods within the controller you are using and pass them arguments as needed. Alternatively, you can set up a library/helper containing the calculations if you are going to use them multiple times.

Code:
class Some_Controller extends Controller {

     function __construct()
     {
          parent::Controller();

          $this->load->model('products_model')
     }

    function index()
    {
        $products = $this->products_model->getProducts();

         foreach ($products as $product) {
              echo 'Product ID: ' . $product->prod_id;
              echo 'Stock Value: ' . $this->_stockValue( $product->stockLevel, $product->unitPrice );
         }
    }

    function _stockValue($stockLevel = 0, $unitPrice = 0)
    {
         return $stockLevel * $unitPrice
    }
    
}


Messages In This Thread
Create a custom object from DB result()? - by El Forum - 11-27-2010, 09:48 AM
Create a custom object from DB result()? - by El Forum - 11-27-2010, 10:38 AM
Create a custom object from DB result()? - by El Forum - 11-27-2010, 02:28 PM
Create a custom object from DB result()? - by El Forum - 11-27-2010, 02:55 PM
Create a custom object from DB result()? - by El Forum - 11-27-2010, 05:13 PM
Create a custom object from DB result()? - by El Forum - 11-27-2010, 05:43 PM
Create a custom object from DB result()? - by El Forum - 12-02-2010, 05:55 PM



Theme © iAndrew 2016 - Forum software by © MyBB