Exemplo n.º 1
0
 /**
  * @param string $data
  * @param int $section
  * @param bool $regex
  * @return array
  */
 public function searchString($data, $section, $regex = false)
 {
     if ($this->dependency) {
         return parent::searchString($data, $section, $regex);
     }
     /* @var SPdb $db */
     $db = SPFactory::db();
     $sids = array();
     try {
         $query = array('oType' => 'field_option', 'fid' => $this->fid, 'sValue' => $regex ? $data : "%{$data}%");
         $db->select('sKey', 'spdb_language', $query);
         $fids = $db->loadResultArray();
         if (count($fids)) {
             foreach ($fids as $opt) {
                 $db->dselect('sid', 'spdb_field_option_selected', array('copy' => '0', 'fid' => $this->fid, 'optValue' => $opt));
                 $ids = $db->loadResultArray();
                 if (is_array($ids) && count($ids)) {
                     $sids = array_unique(array_merge($ids, $sids));
                 }
             }
         }
     } catch (SPException $x) {
         Sobi::Error($this->name(), SPLang::e('CANNOT_SEARCH_DB_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
     }
     return $sids;
 }