Posts tagged with postgresql

  • Yii2 and Postgresql

    This is a quick note about my favorite PHP framework (Yii2) which I used recently.

    Postgresql File Upload

    1.  // upload handling
    2.  // retrieve upload file if is a post
    3.  if($model->load(...))
    4.  {
    5.    $uploadFile = UploadedFile::getInstance($model, 'some_file');
    6.  }
    7.   
    8.  if(validateSuccess)
    9.  {
    10.    // retrieve tmp file content and convert to hex to store into bytea
    11.    $model->byteaColumn = bin2hex( file_get_contents($uploadFile->tempName) ); 
    12.    ...
    13.    $model->save();
    14.  }

    Postgresql File Download Script

    1.  $response = \Yii::$app->response;
    2.  $response
    Read More