How to modify the default search so that he could look at something like 1,2,3 line like type 2 or 2,3 or 1,3 ? even then it was used to idelano podskazadi how to do a search on the basis of chekbokslista . Well type , select the item and 1,3 on the basis of his doing a search.
$ criteria-> addSearchCondition ('m_complect', $ this-> m_complect, true, 'LIKE');
fails to find the value of 1,3 not 1,6
need a query of the form
FROM
tbl_motor
where m_complect
like '%1%6% ';
and he makes
tbl_motor
where m_complect
like '%1,6%';
and if so it does not change correctly
$ criteria-> addSearchCondition ('m_complect', str_replace (",", "%", $ this-> m_complect), true, 'LIKE');
The problem is the third parameter, it shouldn't be true because that will scape any % symbol, you'll need to do it like this:
$mComplectValue = sprintf("%%%s%%", str_replace (",", "%", $this->m_complect));
$criteria->addSearchCondition('m_complect', $mComplectValue, false);
I'm using sprintf
to avoid any SQL injection. But you can also do it like this:
$mComplectValue = '%' . str_replace (",", "%", $this->m_complect) . '%';
$criteria->addSearchCondition('m_complect', $mComplectValue, false);
For more info check CDBCriteria documentation.