您好,欢迎访问一九零五行业门户网

万能单条件查询函数

万能单条件查询函数,如代码。
函数getx2x有四个参数:
第一个参数[必须]为表名;
第二个参数[必须]为字段名;
第三个参数[必须]为所查询字段的值。
第四个参数[可选]为所查询的字段名,未填默认为'id'。
//例子1:
//要查询think_user表中,id=12的用户名:
$username=getx2x('user','username','12');
//或
$username=getx2x('user','username','12','id');
注:此时$u
函数代码请放于位于项目目录下common/common.php中//万能单条件查询函数,由lisan制作
    function getx2x($table,$fields,$id,$str){
        $aa=m($table);
        if(empty($str)){
            $expression='getbyid';
        }else{
            $expression='getby'.$str;
        }
        $thisaa=$aa->field($fields)->$expression($id);
$bb=explode(',',$fields);
        if(count($bb)            return $thisaa[$fields];
        }else{
            return $thisaa;
        }        
    }
ad:真正免费,域名+虚机+企业邮箱=0元
其它类似信息

推荐信息