## LINK 模糊查找条件 接下来我们看一下模糊匹配 Like语句 LIKE 使用语法 [~] . ~~~ <?php namespace Action; use HY\Action; class Index extends Action { public function Index(){ //实例User表为对象 $User = M("User"); // 默认情况下,使用%在前后包含关键词 $User->select("id", array( "city[~]" => "lon" )); WHERE "city" LIKE '%lon%' // 数组形式,查询多个关键词 $User->select("id", array( "city[~]" => array("lon", "foo", "bar") )); WHERE "city" LIKE '%lon%' OR "city" LIKE '%foo%' OR "city" LIKE '%bar%' // 不包含 [!~] $User->select("id", array( "city[!~]" => "lon" )); WHERE "city" NOT LIKE '%lon%' // 使用SQL自带的一些通配符 // 你可以使用sql自带的一些通配符来完成较复杂的查询 $User->select("id", array( "city[~]" => "stan%" // Kazakhstan, Uzbekistan, Türkmenistan )); $User->select("id", array( "city[~]" => "Londo_" // London, Londox, Londos... )); $User->select("id", array( "name[~]" => "[BCR]at" // Bat, Cat, Rat )); $User->select("id", array( "name[~]" => "[!BCR]at" // Eat, Fat, Hat... )); } } ~~~