Home >php教程 >PHP源码 >ThinkPHP万能单条件查询函数

ThinkPHP万能单条件查询函数

PHP中文网
PHP中文网Original
2016-05-25 17:08:391285browse

php代码

//万能单条件查询函数,由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;
		}		
	}
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn