Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

Some Problem By Inserting In Database.

$
0
0
I have model which handle my file uploading. everything ok.
but when it run the save() method, in the datebase insert 2 record and then insert my uploaded file name record.
what is the problem?:unsure:
this is my controller action:
public function actionCreate() {
    	$model = new Picture;
    	if (isset($_POST['Picture'])) {
        	$rnd = rand(0, 9999);
        	$model->attributes = $_POST['Picture'];

        	$uploadFile = CUploadedFile::getInstance($model, 'address');
        	
        	$model->address = "{$rnd}-{$uploadFile}";
        	
        	if ($model->save()) {
                	$uploadFile->saveAs(Yii::app()->basePath . '/../upload/' . "{$rnd}-{$uploadFile}");
            	//$this->redirect(array('view', 'id' => $model->id));
        	}
    	}

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

Viewing all articles
Browse latest Browse all 18717

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>