- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
$dbh = new PDO("mysql:host=$this->dbHost;dbname=$this->dbName", $this->dbUser, $this->dbPassword);
$dbh->exec("set names utf8");
$street = $streetPart.'%';
if (isset($arChooseCity[$cityIndex])) {
$condition =
"(city_az LIKE '$city'"
." OR city_az LIKE '$arChooseCity[$cityIndex]'"
." OR city_ru LIKE '$arChooseCity[$cityIndex]'"
." OR city_en LIKE '$arChooseCity[$cityIndex]'"
." OR city_ru LIKE '$city'"
." OR city_en LIKE '$city')"
." AND (geo_az LIKE '$street'"
." OR geo_ru LIKE '$street'"
." OR geo_en LIKE '$street'"
." OR geo_az LIKE '% $street'"
." OR geo_en LIKE '% $street'"
." OR geo_ru LIKE '% $street')"
;
}
else {
$condition =
"(city_az LIKE '$city'"
." OR city_ru LIKE '$city'"
." OR city_en LIKE '$city')"
." AND (geo_az LIKE '$street'"
." OR geo_ru LIKE '$street'"
." OR geo_en LIKE '$street'"
." OR geo_az LIKE '% $street'"
." OR geo_en LIKE '% $street'"
." OR geo_ru LIKE '% $street')"
;
}
$condition_type = " AND type = 'geo_object'";
$condition_street = " AND type = 'street'";
$query_street = $dbh->prepare("SELECT * from `addresses_new_new` WHERE $condition $condition_street GROUP BY street_{$lang}, city_{$lang} ORDER BY weight DESC LIMIT 0, {$maxLimit}");
$query_type = $dbh->prepare("SELECT * from `addresses_new_new` WHERE $condition $condition_type LIMIT 0, {$maxLimit}");
$query_street->execute();
$query_type->execute();
Vasiliy 18.11.2015 15:34 # 0
inkanus-gray 18.11.2015 15:41 # 0
В таких случаях лучше вообще использовать внешний индексатор типа Sphinx или mnoGoSearch.
Vasiliy 18.11.2015 16:18 # +1
https://dev.mysql.com/doc/refman/5.7/en/innodb-fulltext-index.html
>внешний индексатор типа Sphinx или mnoGoSearch.
ИМХО лучшее решение
guest 19.11.2015 23:25 # +2
bormand 19.11.2015 23:28 # 0
GomnoSearch
PureChaos 19.11.2015 15:54 # +2
Конечно, это не для таких тупых алкашей как ты!
Vasiliy 19.11.2015 17:00 # −1
guest 19.11.2015 23:17 # +1
Чушь полная.
PDO это не ORM а драйверонезависимый способ запуска SQL кода.
Даже твой "LIMIT 0" не на каждой БД заведется
guest 19.11.2015 23:16 # +1
Талант PHPшника не пропьешь
inkanus-gray 20.11.2015 00:23 # 0
guest 20.11.2015 01:53 # 0
guest 21.11.2015 21:29 # 0
akanit 21.11.2015 22:15 # 0
guest 31.01.2017 01:35 # 0
inkanus-gray 31.01.2017 01:48 # +1