mysql - Invalid parameter number error using DataTables with Laravel -


When database tries to obtain data, it always goes to this unique query:

  item = item :: select ([db :: raw ("images.url AS image"), 'item id.', 'Item.squo', 'item qualification', db :: raw ("If enabled (as 'Images.imageable_id', '=', 'james', 'james', 'yes', 'no')) - gt; leftJoin ('images', function ($ j) ) {$ J-> Object.id '} -> where (' images.imageable_type ',' = ',' item ');}); & Gt; Left zones ('command_times', 'item.id', '=', 'command_items.ITEM_id') - & gt; Left zone ('order', 'order .id', '=', 'order_items.order_id') - & gt; Where ('items.store_id', 1) - & gt; Where tap ('items.deleted_at') - & gt; In where ('items.status', ['active', 'submit']) - & gt; GroupB ('items .id');  

This query works fine and gives the desired results, however, DataTables tries to convert it to the following which causes an error:

  count Select from (*) as the total ('1' to be included in the 'images' as line from `item')` images` .`imageable_id` = `item```````` And `image` .amjibal_type type =` 1 remaining `items are added to` order_itim`. `` `` Order_itim```tim_id`` `` `` `` `` `` `` `` `` `` `` `` `` ` `` `'' '' '' '' '' '' '' '' '' / Code>  

This particular error Produces:

  SQLSTATE [HY093]: Invalid parameter number / home / immigration / project / test.dev / vendor / larval / framwork /src/Illuminate/Database/Connection.php#301  

When I execute that query directly on the MySQL database, then there is no problem in it. It seems that what is happening inside Laravel only.

If I type -> If there is no error in the left zone ('image', function ($ j) {...} query, but I need to connect to the image.

This How to reach error around?

Full error output on datatable on AJX:

  {"error": {"type": "illuminate \\ database \\ queryException" , "Message": "SQLSTATE [HY093]: Invalid parameter number (SQL): Select from count (*) as a total (select '1' as row from 'item'` images' on `images` In Join `` `` `` `` `` `` `` `` `` `` `` `` `` `` `` `` `` ` "` `` `` `` `` `` `` `` `` `` `` `` `` `` ` `` `` `/ Home \ / vagrant \ '` `` `` `` AC / count_row_table as "test / ')" empty and `item' dev / vendor / laravel / frame \ / src \ / brighten \ / datab ase / connection.php", "line": 625}}   

This exact issue I had with was not perfect about the work because It will basically catch all the data twice, but this is the only way Land that I can I make it work.

Give you a -> Get (); before sending it to -> Made (); . I honestly hope that someone can find the right solution, but for now:

temporary solution:

DB :: table ('some_table' ); ('Some_table.id', '=', 'some_other_table.id') - & gt; Where ('some_table.Something') $ data- & gt; Omitted ('some_other_table', function ($ included) {$ join->, '=', 'some_mana');}); $ Data- & gt; Find (); Return data :: of ($ data) - & gt; Made ();

It is with the use of a datatable package for Laravel:


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -