1、like 模糊查询
如果后面跟:
你%:表示以“你”开头任意多少去匹配
你 _ : 表示以“你”开头的两个字的
2、范围查询 关键字 in
如果想要查询id为123456的数据
‘id' in(1,2,3,4,5,6)
3、sort : 对数组排序
<?php
$fruits = array("lemon", "orange", "banana", "apple");
sort($fruits);
foreach ($fruits as $key => $val) {
echo "fruits[" . $key . "] = " . $val . " ";
}
?>
以上例程会输出:
fruits[0] = apple fruits[1] = banana fruits[2] = lemon fruits[3] = orange
fruits 被按照字母顺序排序。
4、asort:对数组进行排序并保持索引关系
<?php
$fruits = array("d" => "lemon", "a" => "orange", "b" => "banana", "c" => "apple");
asort($fruits);
foreach ($fruits as $key => $val) {
echo "$key = $val ";
}
?>
以上例程会输出:
c = apple b = banana d = lemon a = orange
fruits 被按照字母顺序排序,并且单元的索引关系不变。
5、arsort:对数组进行逆向排序并保持索引关系
<?php
$fruits = array("d" => "lemon", "a" => "orange", "b" => "banana", "c" => "apple");
arsort($fruits); foreach ($fruits as $key => $val) {
echo "$key = $val ";
}
?>
以上例程会输出:
a = orange d = lemon b = banana c = apple
fruits 被按照字母顺序逆向排序,并且单元的索引关系不变。
6、ksort: 对数组按照键名排序
<?php
$fruits = array("d"=>"lemon", "a"=>"orange", "b"=>"banana", "c"=>"apple");
ksort($fruits); foreach ($fruits as $key => $val) {
echo "$key = $val ";
}
?>
以上例程会输出:
a = orange b = banana c = apple d = lemon
7、krsort:对数组按照键名逆向排序
<?php
$fruits = array("d"=>"lemon", "a"=>"orange", "b"=>"banana", "c"=>"apple");
krsort($fruits); foreach ($fruits as $key => $val) {
echo "$key = $val ";
}
?>
以上例程会输出:
d = lemon c = apple b = banana a = orange
8、rsort:对数组逆向排序
<?php
$fruits = array("lemon", "orange", "banana", "apple");
rsort($fruits); foreach ($fruits as $key => $val) {
echo "$key = $val ";
}
?>
以上例程会输出:
0 = orange 1 = lemon 2 = banana 3 = apple
fruits 被按照字母顺序逆向排序。