i have an eloquent model with url and data, and other standard laravel fields.
then i do:
$cache = new \App\Cache();
$cache->url = $this->url;
$cache->data = json_encode($data);
$cache->save();
when url have no query string, it works perfectly, but when url have query string, laravel generate wrong query such as:
original data:
$this->url = 'https://some-url.com?param1=val1¶m2=val2';
$data = ['some' => 'long', 'json' => 'data'];
turns to:
insert into `cache` (`url`, `data`, `updated_at`, `created_at`)
values (
https://some-url.com{"some":"long","json":"data"}param1=val1¶m2=val2,
2019-01-07 07:38:15,
?,
?
)
as you can see, the encoded json is put on the wrong place (on the ? of the query string)
what did i do wrong? or this is a bug?
note: i'm using mysql
update: removed the error string as it distracting to the main issue
urlcolumn in database?urlcolumn. Try doing that.?as placeholders for data in queries.