I need to make query like this:
SELECT p.pid, p.url FROM products as p WHERE url_crc IN (FNV_64("http://url1.com/"),FNV_64("http://url2.com/"))
I need to use FNV_64 hash function for every array variable. I CAN'T make hashes before passing variables to query builder. This hash functions is only avaliable as MySQL extension.
How can i make this using Symfony2 ? For example, using:
$qb = $em->createQueryBuilder();
$query = $qb->select('p.pid')
->from('SRC\MainBundle\Entity\Product', 'p')
->where('p.url_crc IN (FNV_64(:urls))') // error HERE
->setParameter('urls', $hashes_array)
->getQuery();
Wouldn't work. The only way i can this of is:
$query = $em->createNativeQuery('SELECT p.pid, p.url FROM products as p
WHERE url_crc IN (' . join(',', $tmp_array) . ')', $rsm);
Where tmp_array looks like this:
Array
(
[0] => FNV_64("http://url1.com/")
[1] => FNV_64("http://url2.com/")
)
Is there better way ?