3

I do have table called zipcodes. The length of a zipcode is five. How can I create a query in Doctrine that I get the result, when I only submit 3 characters to the query.

Example:

$search_zipcode = 123*

Table: 
Id  Zipcode
1 - 12345
2 - 12346
3 - 98123
4 - 91238

The result ist just id 1 and 2. I don't want to have id 3 and 4.

Thanks!

Gunnar

craphunter
  • 961
  • 2
  • 13
  • 34

1 Answers1

3

Use the LIKE operator and % wildcard

->where('z.ZipCode LIKE ?', array($search_zipcode . '%')
Phil
  • 157,677
  • 23
  • 242
  • 245