Error:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'id' in 'where clause' (SQL: update `genre_books` set `provider_id` = ?, `genre_id` = ? where `id` is null) (Bindings: array ( 0 => 3, 1 => 466284, ))
It's adding some data successfully but in that table but it still gets this error around in the middle of updating.
Model:
class GenreBook extends Eloquent {
public $table = 'genre_books';
public $timestamps = false;
public $publicKey = 'book_id';
public function setRank($a) {
$this->sort_order = $a;
}
public function setProviderId($a) {
$this->provider_id = $a;
}
public function setBookId($a) {
$this->book_id = $a;
}
public function setGenreId($a) {
$this->genre_id = $a;
}
}
Code in controller:
GenreBook::unguard();
foreach($bookList as $genreId => $books) {
if(count($books) > 0) {
foreach ($books as $book) {
$genreBookRecord = GenreBook::where('book_id',$book['asin'])->where('provider_id',3)->first();
$newGenreBook->setProviderId(3);
$newGenreBook->setBookId($book['asin']);
$newGenreBook->setRank($book['rank']);
$newGenreBook->setGenreId($genreId);
$newGenreBook->save();
}
}