0
私はアプリケーションを持っていますが、データを更新したいのですが、データを変更せずにデータを更新したいときにシステムにエラーがあります。しかし私がデータの1つを正常に更新した場合。エラーSQLSTATE [42000] Laravel Update
ここに私のコントローラ:ここ
<form method='post' action='{{action("[email protected]")."/$row->id" }}' enctype="multipart/form-data">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<div class="box-body">
<div class="box-body">
<div class='form-group col-sm-12'>
<label>Title</label>
<input type='text' class='form-control' name='title' value='{{ @$row->title }}' readonly />
</div>
<div class='form-group col-sm-4'>
<label>gambar</label><br>
<img src="../../uploads/{{ $row->photo1 }}" height="70px">
<input type='file' class='form-control' name='photo1' value='{{ @$row->photo1 }}'/>
</div><br>
<div class='form-group col-sm-4'>
<label>gambar</label><br>
<img src="../../uploads/{{ $row->photo2 }}" height="70px">
<input type='file' class='form-control' name='photo2' value='{{ @$row->photo2 }}'/>
</div>
<div class='form-group col-sm-4'>
<label>gambar</label><br>
<img src="../../uploads/{{ $row->photo3 }}" height="70px">
<input type='file' class='form-control' name='photo3' value='{{ @$row->photo3 }}'/>
</div>
<div class='form-group col-sm-4'>
<label>gambar</label><br>
<img src="../../uploads/{{ $row->photo4 }}" height="70px">
<input type='file' class='form-control' name='photo4' value='{{ @$row->photo4 }}'/>
</div>
<div class='form-group col-sm-4'>
<label>gambar</label><br>
<img src="../../uploads/{{ $row->photo5 }}" height="70px">
<input type='file' class='form-control' name='photo5' value='{{ @$row->photo5 }}'/>
</div>
<div class='form-group col-sm-12'>
<button type='submit' class='btn btn-primary'><i class='fa fa-save'></i> Simpan</button>
</div>
</div><!-- /.box -->
</form>
私のテーブル :
public function getDetails($id) {
$data['row'] = data_kos::find($id);
return view('details_add',$data);
}
public function postDetailsSave($id) {
$simpan= array();
if (Request::hasfile('photo1')) {
$destinationPath = 'uploads'; // upload path
$extension = Request::file('photo1')->getClientOriginalExtension(); // getting image extension
$fileName = rand(11111,99999).'.'.$extension; // renameing image
Request::file('photo1')->move($destinationPath, $fileName); // uploading file to given path
$simpan['photo1']=$fileName;
}
if (Request::hasfile('photo2')) {
$destinationPath1 = 'uploads'; // upload path
$extension1 = Request::file('photo2')->getClientOriginalExtension(); // getting image extension
$fileName1 = rand(11111,99999).'.'.$extension1; // renameing image
Request::file('photo2')->move($destinationPath1, $fileName1); // uploading file to given path
$simpan['photo2']=$fileName1;
}
if (Request::hasfile('photo3')) {
$destinationPath2 = 'uploads'; // upload path
$extension2 = Request::file('photo3')->getClientOriginalExtension(); // getting image extension
$fileName2 = rand(11111,99999).'.'.$extension2; // renameing image
Request::file('photo3')->move($destinationPath2, $fileName2); // uploading file to given path
$simpan['photo3']=$fileName2;
}
if (Request::hasfile('photo4')) {
$destinationPath3 = 'uploads'; // upload path
$extension3 = Request::file('photo4')->getClientOriginalExtension(); // getting image extension
$fileName3 = rand(11111,99999).'.'.$extension3; // renameing image
Request::file('photo4')->move($destinationPath3, $fileName3); // uploading file to given path
$simpan['photo4']=$fileName3;
}
if (Request::hasfile('photo5')) {
$destinationPath4 = 'uploads'; // upload path
$extension4 = Request::file('photo5')->getClientOriginalExtension(); // getting image extension
$fileName4 = rand(11111,99999).'.'.$extension4; // renameing image
Request::file('photo5')->move($destinationPath4, $fileName4); // uploading file to given path
$simpan['photo5']=$fileName4;
}
DB::table('data_kos')->where('id', $id)->update($simpan);
Session::flash('edit', 'Data successfully edited');
return Redirect::to('home');
}
、ここで私の見解 誰も私に解決策を与えることができますか?私の問題
私はそれをどのように使用するのか手がかりを与えることができますか? –
この行 'DB :: table( 'data_kos') - > where( 'id'、$ id) - > update($ simpan);の直前にこの行' dd($ simpan);を置くと、変数にはどのようなデータが含まれていますか。 – IzzEps
ahhですが、その変数が空であることを確認する '[]' –