searchFor() public method

Base implementation, perform string matching search. The standard wildcards * (many characters) and ? (a single character) are supported.
public searchFor ( string $strPattern ) : int[]
$strPattern string The text to search for. This may contain wildcards.
return int[] the ids of matching items.
コード例 #1
0
 /**
  * Search all items that match the given expression.
  *
  * Base implementation, perform string matching search.
  * The standard wildcards * (many characters) and ? (a single character) are supported.
  *
  * @param string $strPattern The text to search for. This may contain wildcards.
  *
  * @return int[] the ids of matching items.
  */
 public function searchFor($strPattern)
 {
     // If search with wildcard => parent implementation with "LIKE" search.
     if (false !== strpos($strPattern, '*') || false !== strpos($strPattern, '?')) {
         return parent::searchFor($strPattern);
     }
     // Not with wildcard but also not numeric, impossible to get decimal results.
     if (!is_numeric($strPattern)) {
         return array();
     }
     // Do a simple search on given column.
     $query = $this->getMetaModel()->getServiceContainer()->getDatabase()->prepare(sprintf('SELECT id FROM %s WHERE %s=?', $this->getMetaModel()->getTableName(), $this->getColName()))->execute($strPattern);
     return $query->fetchEach('id');
 }