- //万能单条件查询函数,由lisan制作
- //函数代码请放于位于项目目录下Common/Common.php中
- 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)<=1){
- return $thisaa[$fields];
- }else{
- return $thisaa;
- }
- }
- //该片段来自于http://www.codesnippet.cn/detail/060920135695.html
来源: http://www.codesnippet.cn/detail/060920135695.html