Yii Concat Cdbexpression('now()') On Create (Insert)

Hi Everybody,

I would like to achieve the following:




public function actionCreate() {

    $model = new Kooperacio;


    if (isset($_POST['Kooperacio'])) {

        $model->setAttributes($_POST['Kooperacio']);

        $model->date = new CDbExpression('NOW()');

        $model->nev = Partner::model()->findByPk($this->partnerId)->nev . ' ' . $model->date;


        if ($model->save()) {

            if (Yii::app()->getRequest()->getIsAjaxRequest())

                Yii::app()->end();

            else

                $this->redirect(array('view', 'id' => $model->id));

        }

    }


    $this->render('create', array('model' => $model));

}



this is the point:




$model->nev = Partner::model()->findByPk($this->partnerId)->nev . ' ' . $model->date;



Result: Partner NOW()

I know this is not working like this, but I have tried a lot of different things already and it’s still not working.

Can somebody please point me to the right direction?

Thanks

BR

c

Hi,

can you explain what you’re trying to do?

You seems to look for concatenate, but i’m not understand what exactly.

hi,

I would like to insert for example the following data into the db table field: Partner 2013-06-06 15:55:00.

Then it’s just something like




$model->nev = 'Partner ' . $model->date;



or




$partner = Partner::model()->findByPk($this->partnerId);

$model->nev = partner->nev . ' ' . $model->date;