Jump to content

Unknown column '0' in 'field list'


pRieStaKos

Recommended Posts

I'm trying to copy a row from a table to another table with Laravel Query and I get the following error.

 

$invoice = Capsule::table('tblinvoices')->where('id', $invoiceid)->get(); //array
$copiedInvoiceid = Capsule::table('mod_myinvoices')->insertGetId(array($invoice));

 

Error: SQLSTATE[42S22]: Column not found: 1054 Unknown column '0' in 'field list' (SQL: )

 

I've used

CREATE TABLE mod_myinvoices LIKE tblinvoices

to create mod_myinvoices table.

 

Any suggestions ?

 

UPDATE

 

I switched to

 

$invoice = Capsule::table('tblinvoices')->where('id', $invoiceid)->first(); 
$copiedInvoiceid = Capsule::table('mod_myinvoices ')->insertGetId((array)$invoice);

 

and works like a charm...:idea:

Edited by priestakos
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated