站长资源网络编程
php SQL之where语句生成器
简介复制代码 代码如下://生成where字符串 function get_where($arg = null) { foreach ((array)$arg as $key => $val) { if(is_int($key)) { $where .= " $val "; }else { if(is_
复制代码 代码如下:
//生成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;
}
//生成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;
}
最新资源
- 群星《天赐的声音第五季 第5期》[320K/MP3][118
- 群星《天赐的声音第五季 第5期》[FLAC/分轨][29
- 群星《歌手2024 第3期》[320K/MP3][78.45MB]
- 群星《歌手2024 第3期》[FLAC/分轨][204.16MB]
- 群星《乘风2024 第6期》[320K/MP3][57.95MB]
- 群星《乘风2024 第6期》[FLAC/分轨][170.72MB]
- 陈立强1995-我爱你胜过这世界[福茂][WAV+CUE]
- 群星-《2014年十大发烧唱片精选HQCD》[低速原抓
- 群星2013-青春缤纷辑压箱宝大公开3CD2[新加坡限
- 林育群.2013-BalladShow(日本版)【环球】【WAV+