Kap*_*rma 1 propel symfony1 symfony-1.4
我正在尝试在我的查询中添加以下条件
AND momento_distribution.MOMENTO_IDMEMBER IN ( 5, 1, 3, 10, 11, 12, 18, 32, 51, 6 )
Run Code Online (Sandbox Code Playgroud)
为此,我有以下代码
$friendCsv=Friend::getFriendIdAsCsv($member); //returning string 5, 1, 3, 10, 11, 12, 18, 32, 51, 6
//code
$c->add(MomentoDistributionPeer::MOMENTO_IDMEMBER, $friendCsv, Criteria::IN);
Run Code Online (Sandbox Code Playgroud)
查询失败,因为它正在生成
AND momento_distribution.MOMENTO_IDMEMBER IN ( '5, 1, 3, 10, 11, 12, 18, 32, 51, 6' )
Run Code Online (Sandbox Code Playgroud)
在字符串上添加单引号.如果我手动删除该单引号,查询将成功运行.
有没有办法强制推动不要将单引号放在值中?
小智 5
试试看
$friendCsv=Friend::getFriendIdAsCsv($member); //returning string 5, 1, 3, 10, 11, 12, 18, 32, 51, 6
$friendArr= explode(',', $friendCsv);
//code
$c->add(MomentoDistributionPeer::MOMENTO_IDMEMBER, $friendArr, Criteria::IN);
Run Code Online (Sandbox Code Playgroud)
Criteria :: IN应该与数组一起使用而不是CSV.