I know that this has to be obvious and I already fear the answer, but I can’t find where I’m stuck, so I need to ask.
How it is possible, that code like this:
$offNum = app()->config->getValue('mainTopOffer'.$off, 0);
$model = Offers::model()->findByPk((int)$offNum, 'status > :status', array(':status'=>0));
if($model != null)
{
echo('Model found for item no '.$offNum.'<br />');
echo('ID = '.$model->id.'<br />');
echo('status = '.$model->status.'<br />');
++$offersCount;
}
echo('model NOT found for item no '.$offNum.'<br />');
Is generating output like this:
Start here and tell him that $offersCount = 0
Model found for item no 2
ID = 2
status = 1
model NOT found for item no 2
Model found for item no 3
ID = 3
status = 1
model NOT found for item no 3
Model found for item no 4
ID = 4
status = 1
model NOT found for item no 4
Stop here and tell him that $offersCount = 3
WTF? How it is possible, that code for both condition satisfied (if) and not satisfied (else) is being fired in the very same time and for each iteration? I’m completely lost! :[
The internal one I use at my company. It is designed the way that most situations has both options (true/false) and therefore there is no "else" part in condition command. And if someone runs into situation where there is only one result of condition evaluation he simply writes an empty branches for second part.
Stupid like a hell, but it has 15 years of history and there is no one in the company right now, having time to change it! :]
Yes, why not! But the problem is that, company has like 25 years of experience / existence and the guy “who started it” is out of the firm for something like around 10 years or more! A very long story, so let’s just not waste precious time on this! Cheers!