mardi 30 mai 2017

Why is Laravel Eloquent generating SQL without quotation marks?

I'm trying to run sudo php artisan migrate db:seed on my Laravel installation and getting the following error:

  [Illuminate\Database\QueryException]                                                                                                          
  Array to string conversion (SQL: insert into `sponsor_phones` (`phone_number`, `type`, `is_primary`, `sponsor_id`, `updated_at`, `created_at  
  `) values (247-216-6255 x4356, Home, 1, 101, 2017-05-30 23:31:59, 2017-05-30 23:31:59))                           

It seems that the SQL Eloquent is creating for seeding lacks quotation marks where they are neede. Adding quotations in the right places (below) allows it to run.

insert into 
`sponsor_phones` 
(`phone_number`,
 `type`, 
 `is_primary`, 
 `sponsor_id`, 
 `updated_at`, 
 `created_at`
 ) 
  values 
  (
  '(732) 540-9730', 
  'Busi', 
  0,
  51, 
  '2017-05-27 21:53:44', 
  '2017-05-27 21:53:44');

I'm not sure what's causing this error, and searching for reasons why Eloquent is not adding quotations seems to be failing to produce any useful results.

I've got a repository up so that you can take a look (and because as an open source project it needs one anyway.)



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2sbUn58
via IFTTT

Aucun commentaire:

Enregistrer un commentaire