donjajo / php-jsondb

A PHP Class that reads JSON file as a database. Use for sample DBs
MIT License
212 stars 56 forks source link

addslashes() expects string #22

Closed kungknut closed 4 years ago

kungknut commented 4 years ago

Hi there!

I really like this library and have come to use it quite a bit.

Tonight I ran over a minor bump when trying to use the to_mysql export function since it seems addslashes() doesn't handle integers. I solved this by typecasting the variable.

https://github.com/donjajo/php-jsondb/blob/5f22a21a9b4293f4fa73e42e3e913ca0afb7bf5c/src/JSONDB.php#L377

return "'" . addslashes( (string) $vv ) . "'";

I'd be happy to submit a PR on this if you like.

donjajo commented 4 years ago

Hello! Great to hear you found this useful. The export to SQL method needs to be revisited actually, its a bit messy down there. Will be back with something! :)

kungknut commented 4 years ago

Hi!

I saw your commit ffc5144. In case this is the final solution to this issue, may I suggest that we close this issue and publish a new release?

donjajo commented 4 years ago

Done - https://github.com/donjajo/php-jsondb/releases

kungknut commented 4 years ago

Thank you!