複製程式碼 程式碼如下:
//產生where字串
function get_where($arg = null) {
foreach ((array)$arg as $key => $val) {
if(is_int($key)) {
$where .= " $val ";
}else {
if (is_string($val)) {
if($val === null) {
$where .= " and $key is null ";
}else {
$where .= "和 $key = '$val' ";
}
}elseif(is_array($val)) {
foreach ($val as $v) {
if(is_string($v)) {
$in .= $in ? ",'$v'" : "'$v'";
}else {
$in .= $in ? ",$v" : "$ v";
}
}
$where .= " and $key in ($in)";
}else {
$where .= " 和 $key = $val " ;
}
}
}
return $where;
}
以上就介紹了symantecpcanywhere php SQL之where語句產生器,包含了symantecpcanywhere方面的內容,希望對PHP教程有興趣的朋友有所幫助。