错误:SQLSTATE [42S22]:找不到列:1054未知列' 0'在'字段列表' (SQL :)

时间:2016-08-28 15:19:48

标签: mysql laravel whmcs

我尝试使用Laravel Query将一行从一个表复制到另一个表,我收到以下错误。

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

错误:SQLSTATE [42S22]:找不到列:1054未知列' 0'在'字段列表' (SQL :)

我已使用CREATE TABLE mod_myinvoices LIKE tblinvoices创建mod_myinvoices表。

有什么建议吗?

2 个答案:

答案 0 :(得分:1)

试试吧!

更改

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

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

答案 1 :(得分:0)

试试吧。

$invoice = Capsule::table('invoices')->where('id', $invoiceid)->get();

$invoiceArr = (array) $invoice[0]; // convert object to array    

$copiedInvoiceid = Capsule::table('myinvoices')->insertGetId($invoiceArr);