We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hello, I'm facing a problem with querybuilder (Symfony 5.4): I've created a basic entity:
/** * @ORM\Entity(repositoryClass=JustipRepository::class) */ class Justip { /** * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") */ private $id; /** * @ORM\Column(type="ip", nullable=true) */ private $ip; public function getId(): ?int { return $this->id; } public function getIp() { return $this->ip; } public function setIp($ip): self { $this->ip = $ip; return $this; } }
in my controller
$ip = Multi::factory('192.168.0.1');
if use the magic method , it 's ok $entities = $this->em->getRepository(Justip::class)->findByIp($ip->getBinary());
$entities = $this->em->getRepository(Justip::class)->findByIp($ip->getBinary());
if use the querybuilder it's not ok
public function findByExampleField($value): array { return $this->createQueryBuilder('j') ->andWhere('j.ip = :val') ->setParameter('val', $value) ->getQuery() ->getResult() ; }
$entities = $this->em->getRepository(Justip::class)->findByExampleField($ip->getBinary());
With findByIp , the runable query is SELECT j0_.id AS id_0, j0_.ip AS ip_1 FROM justip j0_ WHERE j0_.ip = \0x00000000000000000000FFFFC0A80001;
SELECT j0_.id AS id_0, j0_.ip AS ip_1 FROM justip j0_ WHERE j0_.ip = \0x00000000000000000000FFFFC0A80001;
With querybuilder the runable query is SELECT j0_.id AS id_0, j0_.ip AS ip_1 FROM justip j0_ WHERE j0_.ip = 0x00000000000000000000FFFFC0A80001;
SELECT j0_.id AS id_0, j0_.ip AS ip_1 FROM justip j0_ WHERE j0_.ip = 0x00000000000000000000FFFFC0A80001;
I don't know how to tell doctrine that the binary value is binary. Is there something wrong in my code?
The text was updated successfully, but these errors were encountered:
Hi, thanks for reporting this - I'll take a look at this and get back to you!
Sorry, something went wrong.
No branches or pull requests
Hello,
I'm facing a problem with querybuilder (Symfony 5.4):
I've created a basic entity:
in my controller
if use the magic method , it 's ok
$entities = $this->em->getRepository(Justip::class)->findByIp($ip->getBinary());
if use the querybuilder it's not ok
$entities = $this->em->getRepository(Justip::class)->findByExampleField($ip->getBinary());
With findByIp , the runable query is
SELECT j0_.id AS id_0, j0_.ip AS ip_1 FROM justip j0_ WHERE j0_.ip = \0x00000000000000000000FFFFC0A80001;
With querybuilder the runable query is
SELECT j0_.id AS id_0, j0_.ip AS ip_1 FROM justip j0_ WHERE j0_.ip = 0x00000000000000000000FFFFC0A80001;
I don't know how to tell doctrine that the binary value is binary.
Is there something wrong in my code?
The text was updated successfully, but these errors were encountered: