php - Yii rest api insert data in database -


i have problem rest service. i'm new programmer in yii framework , did not create service before. code next:

my controller:

    public function actionlist()      {          $model=new entryfile;             if($_post) {                  $init = cjson::decode(file_get_contents('php://input'));                  $model->attributes=$init['input'];                  $model->eetype=($model->eetype);                  $model->eesize=($model->eesize);                  $model->eefilename=($model->eefilename);                  $model->eefilechecksum=($model->eefilechecksum);                  $model->eeentrypath=($model->eeentrypath);                  }          $model=new outputfile;             if($_post) {                  $init = cjson::decode(file_get_contents('php://input'));                  $model->attributes=$init['output'];                  $model->ofname=($model->ofname);                  $model->ofdocumentpath=($model->ofdocumentpath);                  $model->ofdocumenttype=($model->ofdocumenttype);                   }       } 

entryfile 1 table, , output file onother table... input , output. in postman sent:

{    "input":   {     "eetype": "doc",    "eesize": "1024",     "eefilename": "something",     "eefilechecksum": "23dsdjm34mn4",     "eeentrypath": 1   },    "output":    {      "ofdocumenttype": "pdf",      "ofname": "something",      "ofdocumentpath": 1    }  } 

now need somthing insert data postman database.

did mean this?

$model=new outputfile;         if($_post) {              $init = cjson::decode(file_get_contents('php://input'));              $model->attributes=$init['output'];              if($model->save());                 {                    $this->$model->ofname=($model->ofname);                    $this->$model->ofdocumentpath=($model->ofdocumentpath);                    $this->$model->ofdocumenttype=($model->ofdocumenttype);                  }             // echo "\n".'output podaci:'.print_r($init['output'],1);               } 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -