复制代码 代码如下:
//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 .= " かつ $key が 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 .= " および $key in ($in)";
}else {
$where .= " および $key = $val ";
}
}
}
return $where;
}