I don't know much about indexes in database, so my question can be stupid but... I have parameters for person (name, surname, organization, job etc.), now I'm creating index string in prePersist()
method, something like this:
$this->search_index = $this->name.' '.$this->surname.' '.$this->orgnaization;
with further searching by exploded string with " ", and comparing each part using LIKE
with search_index.
But this looks very crazy. What is the best practice? ps my sample code:
$queryBuilder = $this->createQueryBuilder('s');
foreach(explode(" ", $query) as $key=>$part){
$queryBuilder->orWhere('s.searchindex LIKE:name'.$key)
->setParameter('name'.$key, $part);
}
If I understood you correct, I guess then you are looking for something like this:
$collection = Doctrine::getTable('User')->createQuery('u');
->where('column_name LIKE ?', $this->name)
->orWhere('column_surname LIKE ?', $this->surname)
->orWhere('column_organization LIKE ?', $this->organization)
->execute();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.