Ben laravel için yeniyim ve çalışma amacım için laravel 5.2'deki bir projeyi yapıyorum. Ancak formdaki verileri güncellerken bazı hatalarla karşılaştım. Ekleme, seçme ve silme sorguları herhangi bir hata olmadan düzgün çalışıyor.laravel 5.2: ErrorException: preg_replace(): Parametre uyuşmazlığı, desen bir dizilimdir. Değişken bir dizidir.
ErrorException helpers.php hattı 683 yılında: preg_replace(): Aşağıda verilen bu hata gösteriliyor güncelleme sorgusu kullanırken Ama Parametre uyumsuzluğu yedek verilen bir dizi
in helpers.php line 683
at HandleExceptions->handleError('2', 'preg_replace(): Parameter mismatch, pattern is a string while replacement is an array', 'F:\xampp\htdocs\multidatatechnologies.com\vendor\laravel\framework\src\Illuminate\Support\helpers.php', '683', array('search' => '\?', 'replace' => array(array('menutype' => 'Fast Food', 'status' => '1'), '2'), 'subject' => 'update `menutypes` set `0` = ? where `id` = ?', 'value' => array('menutype' => 'Fast Food', 'status' => '1')))
at preg_replace('/\?/', array('menutype' => 'Fast Food', 'status' => '1'), 'update `menutypes` set `0` = ? where `id` = ?', '1') in helpers.php line 683
at str_replace_array('\?', array(array('menutype' => 'Fast Food', 'status' => '1'), '2'), 'update `menutypes` set `0` = ? where `id` = ?') in QueryException.php line 56
at QueryException->formatMessage('update `menutypes` set `0` = ? where `id` = ?', array(array('menutype' => 'Fast Food', 'status' => '1'), '2'), object(PDOException)) in QueryException.php line 39
at QueryException->__construct('update `menutypes` set `0` = ? where `id` = ?', array(array('menutype' => 'Fast Food', 'status' => '1'), '2'), object(PDOException)) in Connection.php line 653
at Connection->runQueryCallback('update `menutypes` set `0` = ? where `id` = ?', array(array('menutype' => 'Fast Food', 'status' => '1'), '2'), object(Closure)) in Connection.php line 611
at Connection->run('update `menutypes` set `0` = ? where `id` = ?', array(array('menutype' => 'Fast Food', 'status' => '1'), '2'), object(Closure)) in Connection.php line 416
at Connection->affectingStatement('update `menutypes` set `0` = ? where `id` = ?', array(array('menutype' => 'Fast Food', 'status' => '1'), '2')) in Connection.php line 359
at Connection->update('update `menutypes` set `0` = ? where `id` = ?', array(array('menutype' => 'Fast Food', 'status' => '1'), '2')) in Builder.php line 1904
at Builder->update(array(array('menutype' => 'Fast Food', 'status' => '1'))) in AdminController.php line 84
at AdminController->updatemenutype(object(Request))
at call_user_func_array(array(object(AdminController), 'updatemenutype'), array(object(Request))) in Controller.php line 76
at Controller->callAction('updatemenutype', array(object(Request))) in ControllerDispatcher.php line 146
at ControllerDispatcher->call(object(AdminController), object(Route), 'updatemenutype') in ControllerDispatcher.php line 94
at ControllerDispatcher->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in ControllerDispatcher.php line 96
at ControllerDispatcher->callWithinStack(object(AdminController), object(Route), object(Request), 'updatemenutype') in ControllerDispatcher.php line 54
at ControllerDispatcher->dispatch(object(Route), object(Request), 'App\Http\Controllers\AdminController', 'updatemenutype') in Route.php line 174
at Route->runController(object(Request)) in Route.php line 140
at Route->run(object(Request)) in Router.php line 703
at Router->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in VerifyCsrfToken.php line 64
at VerifyCsrfToken->handle(object(Request), object(Closure))
at call_user_func_array(array(object(VerifyCsrfToken), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in StartSession.php line 62
at StartSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure))
at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure))
at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Router.php line 705
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 678
at Router->dispatchToRoute(object(Request)) in Router.php line 654
at Router->dispatch(object(Request)) in Kernel.php line 246
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 44
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Kernel.php line 132
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 99
at Kernel->handle(object(Request)) in index.php line 54
Aşağıda iken, desen bir dize veri (AdminController.php) güncellemek için denetleyici yazılmış benim karşılık gelen fonksiyonudur verilen Aşağıda
<form class="form-horizontal" method="post" action="{{action('[email protected]')}}">
<input type="hidden" name="_token" value="{{csrf_token()}}" />
<input type="hidden" name="eid" value="{{$row->id}}" />
<div class="box-body">
<label>Menu-Type Name:</label>
<div class="input-group">
<div class="input-group-addon">
<i class="fa fa-fire"></i>
</div>
<input type="text" name="menutype" class="form-control" value="{{$row->menutype}}" placeholder="Enter Menu-Type Name..." required="required" maxlength="100">
</div><!-- /.input group -->
</div><!-- /.form group -->
<div class="box-body">
<label>Publishing Status:</label>
<div class="input-group">
<div class="input-group-addon">
<i class="fa fa-globe"></i>
</div>
<select name="status" class="form-control" style="width: 100%;" required="required">
<option value="{{$row->status}}" disabled="disabled"><?php if($row->status==1){echo "Yes"; }else{echo "No";} ?></option>
<option value="1">Yes</option>
<option value="0">No</option>
</select>
</div><!-- /.input group -->
</div><!-- /.form group -->
<div class="box-footer">
<input type="reset" name="reset" class="btn btn-default" value="Cancel">
<input type="submit" name="submit" class="btn btn-info pull-right" value="Edit Menu-Type">
</div>
</form>
: kod güncellemesi formunun görünümü dosyası (editmenutype.blade.php) için benim tarafımdan yazılmıştır
Verilen Aşağıdapublic function editmenutype($id) {
$row = DB::table('menutypes')->where('id',$id)->first();
return view('admin.editmenutype')->with('row',$row);
}
public function updatemenutype(Request $request) {
$post=$request->all();
print_r($post);
//var_dump($post);
$v=\Validator::make($request->all(),
[
'menutype' => 'required',
'status' => 'required',
]);
if($v->fails())
{
return redirect()->back()->withErrors($v->errors());
}
else
{
$data = array(
[
'menutype' => $post['menutype'],
'status' => $post['status'],
]);
$i = DB::table('menutypes')->where('id',$post['eid'])->update($data);
if($i > 0)
{
\Session::flash('message','* Menu-Type Updated Successfully.');
return redirect('/admin/managemenutypes');
}
}
}
i rota dosyası (routes.php) karşılık gelen sayfaları aramak için verilen karşılık gelen kodu şöyledir:
Route::get('admin/editmenutype/{id}','[email protected]');
Route::post('admin/updatemenutype','[email protected]enutype');
Neden güncelleme sorgusu sadece durumunda meydana gelen bu hata? Lütfen bu sorunu düzeltmek için kararlı ve doğru bir yöntemle bana yardımcı olun ... Şimdiden teşekkürler. senin AdminController.php
yılında
Evet. Çok teşekkürler. Şimdi mükemmel çalışıyordu. Ancak ekleme sorgusu durumunda da dizi içinde dizi olarak vermiştim ve mükemmel çalışıyor. O zaman neden dizi içinde dizi olarak verirken güncelleme sorgusu için işe yaramadı? –
Aydınlatıcı dilbilgisi sınıfının ('Illuminate \ Database \ Query \ Grammars \ Grammar') incelenmesi üzerine, ekler, değer dizisini çeken bir' parameterize' işlevi kullanılarak yapılır. Buna rağmen, güncelleme işlevi, 'name = value 'biçiminde bir dize oluşturur, dolayısıyla dizinin içindeki dizinin güncelleme sırasında" 0 = array ", dolayısıyla da kilitlenme olur. – Mysteryos
oh. okok. Konuyla ilgili açıklama için teşekkürler. –