di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">
<preference for="Magento\Framework\DB\Helper\Mysql\Fulltext" type="Vendor\Module\Helper\Mysql\Fulltext" />
</config>
Fulltext.php
namespace Vendor\Module\Helper\Mysql;
use Magento\Framework\App\ResourceConnection;
class Fulltext extends \Magento\Framework\DB\Helper\Mysql\Fulltext
{
/**
* @param ResourceConnection $resource
*/
public function __construct(ResourceConnection $resource)
{
$this->conn = $resource->getConnection();
}
public function getMatchQuery($columns, $expression, $mode = self::FULLTEXT_MODE_NATURAL)
{
if(is_array($columns) && count($columns) > 1)
return parent::getMatchQuery($columns, $expression, $mode);
$columns = is_array($columns) ? array_pop($columns):$columns;
$expression = str_replace('*', '', $expression);
$expression = str_replace('%', '%%', $expression);
$expression = $this->conn->quote('%'.$expression.'%');
$condition = $columns.' LIKE '.$expression;
return $condition;
}
}
Module代码
http://git.oschina.net/willia...
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。