Hi alls, i still newbie & want to ask question. i create a function in Controller.php like this :
public function aftersave($tanda,$id,$set=false,$data='')
{
$connection = Yii::app()->db;
$tabel = $this->tablename($tanda);
$nama = $this->projectname($tanda);
[color="#FF0000"]$current = $nama::model()->findByPk($id);[/color]
}
public function projectname($flags)
{
if($flags == "1")
{
$nama = "MediaSeller";
}
else if($flags == 2)
{
$nama = "ProductCategory";
}
else if($flags == 3)
{
$nama = "Advertiser";
}
return $nama;
}
function tablename($flags)
{
if($flags == 1)
{
$tabel = "tbl_media_seller";
}
else if($flags == 2)
{
$tabel = "tbl_product_category";
}
else if($flags == 3)
{
$tabel = "tbl_advertiser";
}
return $tabel;
}
and add coding in actionCreate() in MediaSellerController.php like this :
public function actionCreate()
{
$model=new MediaSeller;
if(isset($_POST['MediaSeller']))
{
$model->attributes = $_POST['MediaSeller'];
$row = Controller::kueri(1,$model);
if ($row == null)
{
if ($model->save())
{
$last = Yii::app()->db->getLastInsertID();
Controller::aftersave(1,$last);
$this->redirect(array('view','id'=>$model->id));
}
}
else
{
Controller::aftersave(1,$row,true,$_POST['MediaSeller']);
$this->redirect(array('view','id'=>$row));
}
}
$this->render('create',array(
'model'=>$model,
));
}
and if i run in my localhost using php version 5.3 it’s work, but if i run in my server with php version 5.2 it said Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM in Controller.php on line $current = $nama::model()->findByPk($id); in function aftersave
can someone help? thanks