PHP if.. elseif...else 问题
本帖最后由 xytianshiwx 于 2013-12-08 10:09:44 编辑
<br />
<?php<br />
$field_func="COUNT|AVG|FIRST|LAST|MAX|MIN|SUM|TOP";<br />
$where_field="Where|or|xor|and|in";<br />
$param="name";<br />
$sql_param_list=array();<br />
if(false!==strpos($param,",")){//判断是否存在“,”<br />
$sql_param_list["field"] = $param;<br />
}else{<br />
if(preg_match("/\b(".strtolower($field_func).")\b\((\*|[a-zA-Z_`])+\)/i", $param)){<br />
$sql_param_list["field"] =$param;<br />
}elseif(preg_match("/\b(".$where_field.")\b/i", $param)||preg_match("/(>|>|=)/i", $param)){//判断where<br />
$sql_param_list["where"] =$param;<br />
<br />
}elseif(preg_match("/\b(order|limit|group|)\b/i", $param,$param_name)){//判断order|limit|group<br />
switch ($param_name[0]){<br />
case "order" : $sql_param_list["order"] =$param;<br />
break;<br />
case "limit" : $sql_param_list["limit"] =$param;<br />
break;<br />
case "group" : $sql_param_list["group"] =$param;<br />
break;<br />
<br />
}<br />
}else{<br />
$sql_param_list["field"] =$param;<br />
}<br />
} <br />
print_r($sql_param_list);<br />
<br />
Copy after login
$param 没有赋值个$sql_param_list["field"]??
逻辑错误还是其他错误,请高手指点指点!!!
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
-
2024-10-22 09:46:29
-
2024-10-13 13:53:41
-
2024-10-12 12:15:51
-
2024-10-11 22:47:31
-
2024-10-11 19:36:51
-
2024-10-11 15:50:41
-
2024-10-11 15:07:41
-
2024-10-11 14:21:21
-
2024-10-11 12:59:11
-
2024-10-11 12:17:31