多重推进式过滤器
Multiple Propel Like Filters
正在尝试使用 LIKE 按多个条件筛选列。
像这样:
$d = ItemQuery::create()
->filterByName($array_of_names, Criteria::LIKE)
->find();
但是我得到了"Array to string conversion in propel/src/Propel/Runtime/Connection/StatementWrapper.php"
如何使用 "LIKE" 条件按多个 "names" 进行筛选?
我基本上希望查询是
...name LIKE %name1% OR name LIKE %name2% OR name LIKE %name2%...
假设 $array_of_names
是 [$name1, $name2, ...]
$q = ItemQuery::create()
foreach ($array_of_names as $i => $name) {
if ($i > 0) { // Not the first item in the array
$q->_or();
}
$q->where('Item.Name LIKE %?%', $name);
}
$d = $q->find();
见
http://propelorm.org/blog/2012/03/20/don-t-do-this-at-home-5-use-where-instead-of-filterby.html
和
或
正在尝试使用 LIKE 按多个条件筛选列。
像这样:
$d = ItemQuery::create()
->filterByName($array_of_names, Criteria::LIKE)
->find();
但是我得到了"Array to string conversion in propel/src/Propel/Runtime/Connection/StatementWrapper.php"
如何使用 "LIKE" 条件按多个 "names" 进行筛选?
我基本上希望查询是
...name LIKE %name1% OR name LIKE %name2% OR name LIKE %name2%...
假设 $array_of_names
是 [$name1, $name2, ...]
$q = ItemQuery::create()
foreach ($array_of_names as $i => $name) {
if ($i > 0) { // Not the first item in the array
$q->_or();
}
$q->where('Item.Name LIKE %?%', $name);
}
$d = $q->find();
见
http://propelorm.org/blog/2012/03/20/don-t-do-this-at-home-5-use-where-instead-of-filterby.html
和
或