Hello,
I have two Models: oxBasket and oxOrders.
Now in oxOrders I have functions that calculates some result and I want to get it in oxBasket.
How I can do loading of oxBasket class in oxOrders?
Thank you.
Hello,
I have two Models: oxBasket and oxOrders.
Now in oxOrders I have functions that calculates some result and I want to get it in oxBasket.
How I can do loading of oxBasket class in oxOrders?
Thank you.
This is my case:
class Model1{
public $_result = null;
function calculate($num1, $num2){
$res = $num1 + $num2;
$this->_result = $result;
}
function getCalculate(){
return $this->_result;
}
class Model2{
$model1 = oxNew(āModel1ā);
$result = $model1->getClaculate();
}
And I am getting NULL as a result
You donāt call it.
you should quit your job. seriously.
you donāt even know php basics.
first of all: _$result is declared with default value null
When you create new object of class Model1, itās _$result is already null
and when you do this:
you get the default value null because you literally did nothing to change this value.
and second:
find the difference
I cannot call calculate($num1, $num2) from Model2 because I donāt have values for needed parameters in Model2. For that I am using getCalculate() function, to be able to return the result.
For that, I have the problem.
As @vanilla_thunder already said:
$res = $num1 + $num2;
$this->_result = $result;
Just find the difference. Itās not that hard.
You can call calculate in getCalculate. Of course, that depends on when the values are available. When is the function ācalculateā called? Before, after or in parallel?
Before? Then you can save values e.g. in a session
Parallel? Then a direct call is possible. Change your model
Later? Bad
I cannot call calculate in getCalculate because values are not available then.
calculate function is called before getCalculate() with directly from the template.