Hi!
Today I decide to upload my project in hosting for test some possible bugs. But what I forgot to do is to compare the php vesions in local server and hosting. It’s 5.2 in hosting and 5.3 in local. So the majority of my classes doesn’t works at all.
The reason is that I use such style in my methods:
class Media extends CComponent
{
public function Listing($mo, $crit = array(), $paging = 0)
{
$criterion = new CDbCriteria;
$criterion->order = 'id DESC';
// Additional criterion
foreach ( $crit as $k => $v ) {
$criterion->$k = $v;
}
// Enable pagination
if ( $paging > 0 ) {
$qnt = $mo::model()->count($criterion);
$pages = new CPagination($qnt);
$pages->pageSize = $paging;
$pages->applyLimit($criterion);
}
$model = $mo::model()->findAll($criterion);
return array(
'model' => $model,
'pages' => $pages,
);
}
...
}
It’s slice of one class. The method Listing is for helping to display the data. I pass the model name in variable $mo. So the construction $mo::model() doesn’t works in 5.2 ( exception t_paamayim_nekudotayim ).
Should I repeat the same slice of code for each of five models, and only difference is the class name? I just think nobody except me does not write the code with such style
Do you maybe know the way I can replace this stuff with more readable and flexible code?
I know it may has no relation to yii, but I don’t know what if yii has some resolution in this case.