Where statement generator for phpSQL. Copy the code as follows: generate the where string functionget_where ($ argnull) {foreach (array) $ argas $ key $ val) {if (is_int ($ key) {$ where. $ val;} else {if (is_stri
The code is as follows:
// Generate the 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 http://www.bkjia.com/PHPjc/320031.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/320031.htmlTechArticle code is as follows: // Generate the where string function get_where ($ arg = null) {foreach (array) $ arg as $ key = $ val) {if (is_int ($ key) {$ where. = "$ val";} else {if (is_stri...