$search_string="aaaa";
$searchQuery = array(
'$and' => array(
'ispublished'=>"1",
'$or' => array(
array(
'title' => new MongoRegex("/^$search_string/i"),
),
array(
'description' => new MongoRegex("/^$search_string/i"),
)
)
)
);
这是错误说错查询。我想要已经发布1和(标题有aaaa或描述有aaaa)的resullts
答案 0 :(得分:0)
实际上上面的编码有语法错误,有些大括号没有关闭
请尝试以下
$search_string="aaaa";
$searchQuery = array(
'$and' => array(
'ispublished'=>"1",
'$or' => array(
array(
'title' => new MongoRegex("/^$search_string/i"),
),
array(
'description' => new MongoRegex("/^$search_string/i"),
)
)
));