Home > Article > Backend Development > symantecpcanywhere php SQL where statement generator
Copy code The code is as follows:
//Generate where string
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;
}
The above introduces the where statement generator of symantecpcanywhere PHP SQL, including the content of symantecpcanywhere. I hope it will be helpful to friends who are interested in PHP tutorials.