1. 程式人生 > >phalcon在model查詢find中使用in查詢

phalcon在model查詢find中使用in查詢

上程式碼比較直接。希望對大家有用,phalcon的文件是在令人詬病

$types = [1,2,3,4]
$prizeList = Prize::find([
                    "conditions" => 'status = ?0 and app_config_id =?1 and city_id =?2 and game_code =?3 and level =?4 and type IN ({typeList:array})',
                    "order" => 'get_probability DESC, sort DESC',
                    "bind"       => [
                        0 => 1,
                        1 => GOB::APP_CONFIG_ID,
                        2 => $city_id,
                        3 => $gameCode,
                        4 => $this->level,
                        'typeList'=>$type
                    ]
                ]);

使用這種查詢方式就查詢出類似這樣的效果

select * from `prize` where type in ($typeList);