Как правильно передать MATCH..AGAINST в pdo_tools?
Как правильно передать конструкцию MATCH..AGAINST соответственно в SELECT и WHERE?
Собственно сам запрос:
mySql:
Собственно сам запрос:
mySql:
SELECT Product.id, pagetitle, longtitle, price, Data.article,Data.packing,Data.measure, Data.priceOpt, MATCH (pagetitle, longtitle, description, alias, introtext, content, class_key)
AGAINST ('строка поиска' IN NATURAL LANGUAGE MODE) as relevance
FROM `modx_site_content` Product
INNER JOIN `modx_ms2_products` Data ON (Data.id = Product.id)
WHERE class_key = 'msProduct' AND MATCH (pagetitle, longtitle, description, alias, introtext, content, class_key)
AGAINST ('строка поиска' IN BOOLEAN MODE)
ORDER BY relevance DESC;
PDO$q->select("msProduct.id, pagetitle, longtitle, price, msProductData.article,msProductData.packing,msProductData.measure, msProductData.priceOpt");
$q->select("MATCH (pagetitle, longtitle, description, alias, introtext, content, class_key) AGAINST (:qstr1 IN BOOLEAN MODE) as relevance");
$q->where("MATCH (pagetitle, longtitle, description, alias, introtext, content, class_key) AGAINST (:qstr2 IN BOOLEAN MODE)");
$q->innerJoin('msProductData', 'msProductData', 'msProductData.id=msProduct.id');
$q->sortby('relevance','DESC');
Комментарии: 1
Да, собссна, так же и передавай.
$select = array();
$where = array();
$columns = array();
$where['Ticket.id:>='] = 123; // for example
$where[] = 'MATCH (pagetitle, longtitle, description, alias, introtext, content, class_key) AGAINST (:qstr2 IN BOOLEAN MODE)';
$columns[] = '`Ticket`.`id`';
$columns[] = '`Ticket`.`published`';
$columns[] = /* ... */;
$columns[] = 'MATCH (pagetitle, longtitle, description, alias, introtext, content, class_key) AGAINST (:qstr2 IN BOOLEAN MODE) as relevance';
$class = 'Ticket';
$select[] = '"Ticket":"'.$modx->getSelectColumns($class, $class).', '. implode(', ', $columns).'"';
$pdoFetchConfig = array(
'select' => '{'.implode(',',$select).'}',
/* ... */
);
if (count($where)) $pdoFetchConfig['where'] = $modx->toJSON($where);
$pdoFetch = $modx->getService('mypdofetch','mypdoFetch',$modx->getOption('pdotools.core_path',null,$modx->getOption('core_path').'components/pdotools/').'model/pdotools/',$pdoFetchConfig);
Авторизуйтесь или зарегистрируйтесь, чтобы оставлять комментарии.