PHP头条
热点:

phpSQL之where语句生成器


代码如下:
//生成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 .= " and $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 .= " and $key = $val ";
}
}
}
return $where;
}

www.phpzy.comtrue/phpyy/13894.htmlTechArticlephpSQL之where语句生成器 代码如下: //生成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 .=...

相关文章

相关频道:

PHP之友评论

今天推荐