darsyn / ip

Immutable value object for IPv4 and IPv6 addresses, including helper methods and Doctrine support.
http://darsyn.github.io/ip/
MIT License
245 stars 21 forks source link

How to use in where queries #91

Open scuben opened 2 months ago

scuben commented 2 months ago

I cannot manage to create a working query filtering based on the ip. I figure the problem is in packing and unpacking the binary before saving in the database. Or am I missing something?

zanbaldwin commented 2 months ago

Yes, in order to use with the query builder, you'll have to convert to the underlying binary string. This is a limitation I couldn't get around when I first wrote the Doctrine integration, and haven't really addressed it since then.

However, I just spun up a quick project to test out the response I was going to write, but I ran into loads of errors and incompatibilities with the newer DBAL4/ORM3 packages, so it looks like I'm going to be rewriting the Doctrine part now anyway :woman_shrugging:

I'll see if I can figure out how to pass IP objects to query builders and findBy repository methods while I'm fixing everything else!