When I want to update the FaqTrans
database, but this datase have two primary key (faq_ida and lang) $table->primary(array('lang', 'faq_id'));
. so I don't need a id
column with auto_increment.
However, when I use the following code to update the database, the error message hint me there is no id
column.
$faq_trans = FaqTrans::where('faq_id','=',$faq_id)->where('lang','=',$lang)->first();
$faq_trans->lang = Input::get('lang');
$faq_trans->body = Input::get('body');
$faq_trans->title = Input::get('title');
$faq_trans->save();
error message
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'id' in 'where clause' (SQL: update
FAQtrans
setbody
= ?,updated_at
= ? whereid
is null) (Bindings: array ( 0 => 'adfadaaadfadaa', 1 => '2013-07-04 11:12:42', ))
and when I added an id
column, the code works fine...
are there any way can I update the database without ID column ?
Write this line into your Model
public $primaryKey = '_id';
Where _id is your manual primary key
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With