Unusual problem thinkPHP5.1 database query

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/weixin_44289860/article/details/100186646

Problem thinkPHP multi-criteria query

Today learned thinkPHP5.1 database queries, which learn to pit with many conditions encountered.

1. The first is to use two methods to limit where multi-criteria query

public function sel(){
	$res  = db('table_name')->where('id','1')->where('name','Tom')->select();
	
	dump($res);
	
}

Execute the code above: The data appear to meet the conditions of success.
Open the file app.php

    'app_trace'              => false,

Changed

    'app_trace'              => true,

View sql statement executed

‘[ SQL ] SELECT * FROM `user` WHERE `id` = 1 AND `name` = 'Tom' [ RunTime:0.000476s ]

No error

2. Using a two-dimensional array of query conditions

$where = [
	['id,'1'],
	['name','Tom']
		];

	$res = db('user')->where($where)->select();
	
	dump($res);
	

The implementation of Here Insert Picture Description
the error

Therefore, the use of two-dimensional data query conditions must be added =,>, <and so on.

Thanks for watching, there is an error please correct me.

Guess you like

Origin blog.csdn.net/weixin_44289860/article/details/100186646