Closed leereichardt closed 7 years ago
I don't think so.
I don't think so either. As far as I know, REPLACE INTO is a mysql-specific extension so it wouldn't be portable (it's not standard SQL)
I agree. Spot should remain portable.
Thanks. I reverted to creating a custom mapper and building my own way. One thing I found, and it took me a while to realise, is that the ->query
function is for select
only. It might be good to include a simple query function for doing these "other" queries. Once that doesn't return an entity?
I think you can do that. It was merged a while ago: #180 ex.: $mapper->exec($sql);
Or you can extend the Mapper class and implement a custom replace method here to satisfy your needs.
Ah of course! It was a late night alright! Thanks for the help!
There actually is an upsert
function that will attempt to INSERT the record, and then will attempt to UPDATE it instead on duplicate key failure. It is not going to be as efficient as a native REPLACE INTO, but it is fully portable across database drivers.
https://github.com/spotorm/spot2/blob/master/lib/Mapper.php#L881
I can't for the life of me figure this out, but is there a mapper function that does a REPLACE INTO query?