Repository and queries · Question 10 of 12

A search is to find all conferences whose title contains the search term $searchWord. Which constraint is correct?

1 answer is correct. Medium

Show answer

Answer

  • B $query->like('title', '%' . $searchWord . '%')

Explanation

like() works like SQL LIKE: only the % wildcards before and after turn it into a substring search, without them it is an exact comparison. contains() checks whether a multi-valued relation (e.g. an ObjectStorage) contains a certain object, and equals() knows no wildcards. If the search term itself contains % or _, escape them first.

Certifications & exams

Which exam comes next?

You can already practise for 19 exams, and 21 are up for a vote. See all certifications with their official information, cast your vote or suggest your exam.

See all certifications