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

ThinkPHP万能单条件查询函数

PHP中文网
Release: 2016-05-25 17:08:39
Original
1284 people have browsed it

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;
		}		
	}
Copy after login
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template