public function getPatternMatchSites($pattern)
{
$ids = $this->getSitesIdWithAtLeastViewAccess();
if (empty($ids)) {
return array();
}
$ids_str = '';
foreach ($ids as $id_val) {
$ids_str .= $id_val . ' , ';
}
$ids_str .= $id_val;
$db = Db::get();
$bind = array('%' . $pattern . '%', 'http%' . $pattern . '%', '%' . $pattern . '%');
// Also match the idsite
$where = '';
if (is_numeric($pattern)) {
$bind[] = $pattern;
$where = 'OR s.idsite = ?';
}
$sites = $db->fetchAll("SELECT idsite, name, main_url, `group`\n\t\t\t\t\t\t\t\tFROM " . Common::prefixTable('site') . " s\n\t\t\t\t\t\t\t\tWHERE (\t\ts.name like ?\n\t\t\t\t\t\t\t\t\t\tOR \ts.main_url like ?\n\t\t\t\t\t\t\t\t\t\tOR \ts.`group` like ?\n\t\t\t\t\t\t\t\t\t\t {$where} )\n\t\t\t\t\t\t\t\t\tAND idsite in ({$ids_str})\n\t\t\t\t\t\t\t\tLIMIT " . SettingsPiwik::getWebsitesCountToDisplay(), $bind);
return $sites;
}