Search code examples
symfony1symfony-1.4propel

Issue with Propel Criteria::IN


I'm trying as add following condition in my query

AND momento_distribution.MOMENTO_IDMEMBER IN ( 5, 1, 3, 10, 11, 12, 18, 32, 51, 6 )

For that, I'm having following code

$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);

Query is failing because it is generating

AND momento_distribution.MOMENTO_IDMEMBER IN ( '5, 1, 3, 10, 11, 12, 18, 32, 51, 6' )

Adding a single quote on string. If I remove that single quote manually, query runs successfully.

IS there any way to force propel not to put single quotes in values?


Solution

  • try that

    $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);
    

    Criteria::IN should be used with array not CSV.