Hongmu Notes
Home Program Notes Empire cms multi-condition query IN query
Program Notes Empire cms

Empire cms multi-condition query IN query

Empire cms multi-condition query IN query

In EmpireCMS, you may occasionally need to use the `IN` query – specifically, within a multi-condition query:

ad1a1b7183165935

When using this, I noticed that the IN query wasn't returning the expected results; therefore, I searched through the PHP code and found that the following function needed to be modified!

function SearchDoKeyboard($f,$hh,$keyboard){
	// print_r($keyboard);echo "<br>";
	$where='';
	$keyboard=SearchDoKeyboardVar($keyboard);

	if(empty($keyboard))
	{
		return "";
	}
	if(!empty($hh))
	{
		if($hh=='LT')//小于
		{
			$where=$f."<'".$keyboard."'";
		}
		elseif($hh=='GT')//大于
		{
			$where=$f.">'".$keyboard."'";
		}
		elseif($hh=='EQ')//等于
		{
			$where=$f."='".$keyboard."'";
		}
		elseif($hh=='LE')//小于等于
		{
			$where=$f."<='".$keyboard."'";
		}
		elseif($hh=='GE')//大于等于
		{
			$where=$f.">='".$keyboard."'";
		}
		elseif($hh=='NE')//不等于
		{
			$where=$f."<>'".$keyboard."'";
		}
		elseif($hh=='IN')//包含
		{
			
			$kr=explode(' ',$keyboard);
			$kcount=count($kr);
			$kbs='';
			$dh='';
			
			for($i=0;$i<$kcount;$i++)
			{
				$kr[$i]=(float)$kr[$i];
				// print_r($kr[$i]);echo "<br>";
				if(empty($kr[$i]))
				{
					continue;
				}
				if($kbs)
				{
					$dh=',';
				}
				$kbs.=$dh."'".$kr[$i]."'";
			}
			if($kbs)
			{
				$where=$f." IN (".$kbs.")";
			}
			else
			{
				return '';
			}
		}
		elseif($hh=='BT')//范围
		{
			$keyboard=ltrim($keyboard);
			if(!strstr($keyboard,' '))
			{
				return '';
			}
			$kr=explode(' ',$keyboard);
			$kr[0]=(float)$kr[0];
			$kr[1]=(float)$kr[1];
			if(!trim($kr[0])||!trim($kr[1]))
			{
				return '';
			}
			$where=$f." BETWEEN '".$kr[0]."' and '".$kr[1]."'";
		}
		else//相似
		{
			$where=$f." LIKE '%".$keyboard."%'";
		}
	}
	else
	{
		$where=$f." LIKE '%".$keyboard."%'";
	}
	return $where;
}

Simply comment out the following code:

$kr[$i]=(float)$kr[$i];

This code converts a string value to a floating-point type, causing the subsequent data check to return `None`; therefore, simply comment out this line of code.

Perform a direct search – simply locate and delete this line or its associated comment.

 

微信赞赏

WeChat

支付宝赞赏

Alipay

✍️ Author: Hong Mu

webmaster · Thanks for reading, stay tuned for more exciting content

Author homepage View home page →

Related articles

Empire CMS database statement & SQL statement format

Empire CMS database statement & SQL statement format Program Notes Empire cms

Introduction to Imperial CMS extended SQL program writing, basic examples of Imperial CMS database statements & SQL statement formats: Note: The following examples are based on placing PHP files in the system root directory. Example 1: Connect to MYSQL program. (a.php)<?php require('e/class/connect.php'); //Introduce database configuration files and public function files requ…
👁 351
Empire CMS obtains the system COOKIE variable function getcvar()

Empire CMS obtains the system COOKIE variable function getcvar() Program Notes Empire cms

Get the system COOKIE variable function syntax: getcvar($var,$ecms) Description: $var: is the variable name $ecms: 0 is to set the foreground COOKIE variable, 1 is to set the background COOKIE variable. This parameter can be omitted and defaults to 0. Usage example: getcvar('mlusername'), get the user name of the front-end login member getcvar('loginu...
👁 295
Empire CMS smart label call field collection

Empire CMS smart label call field collection Program Notes Empire cms

Collect and classify all fields that support smart tag calls into Empire CMS smart tags: [e:loop={column ID/topic ID, number of items displayed, operation type, only display pictures with titles, additional SQL conditions, display sorting}] Template code content [/e:loop] Calling time: <?=date('m-d',$bqr[newstime])?> <?=dat…
👁 3749

Recommended reading

(Adaptive Mobile Version) Responsive Web Development Software – Mini-Program Development – Website Development – PBootCMS Template 0307

(Adaptive Mobile Version) Responsive Web Development Software – Mini-Program Development – Website Development – PBootCMS Template 0307 Practical Collection pbootcms Template

An adaptive, responsive website and software development mini-program template based on PbootCMS. Featuring a modern, tech-oriented design style, this template is ideal for IT service companies and software development teams to showcase their projects and technical expertise. It helps technology firms attract potential clients seeking development services online. Template Overview | Installation Instructions | Website Backend: /admin.php | Username: admin | Password: admin | Extraction Password: www.4s...
👁 46
PHPStudy 8.2 Extension Fix

PHPStudy 8.2 Extension Fix Program Notes PHP Hobbies

I don’t know what’s wrong with php. After opening the 8.2 version of php, the extension cannot be installed. When opening the php.ini configuration, there is nothing. All, find a piece of content, fill it in, and the problem will be solved. [PHP] engine = On short_open_tag = On precision = 14 output_buffering = 4096 zli…
👁 1
pbootcms sqlite database converted to mysql database

pbootcms sqlite database converted to mysql database Program Notes PbootCms

Why convert to mysql database? When the amount of data in the database reaches tens of thousands, there will be the following differences between using SQLite and MySQL: Performance: SQLite is an embedded database suitable for lightweight applications. It uses disk files to store data and has only one connection. In contrast, MySQL is a complete client/server relational database management system that supports multiple connections and has...
👁 622
Construction Machinery Sales Mall Website Template – 11828 0550

Construction Machinery Sales Mall Website Template – 11828 0550 Practical Collection Yiyou template

An EyouCMS website template designed for construction machinery sales platforms. Its professional engineering-oriented design enables effective display of construction machinery products, second-hand equipment, sales listings, and online consultation services, helping construction machinery trading platforms attract buyers and sellers online. Template Display | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for EyouCMS | EyouCMS...
👁 51
Five doors and ten changes

Five doors and ten changes Hobbies Memo notes

Heavenly Stems --- Five Elements --- Zangfu --- This Point A --- Earth --- Gallbladder --- Linwei B --- Earth --- Liver --- Between the Lines C --- Metal --- Small Intestine --- Yang Gu Ding --- Metal --- Heart --- Shaofu E --- Fire --- Stomach --- Zusanli Ji --- Fire --- Spleen --- Taibai Geng---Wood---Large Intestine---Er Jian Xin---Wood---Lung---Jingqu Ren---Fire---Bear...
👁 203
(PC+WAP) Electrical Equipment Website Template; Mechanical Equipment Website Source Code – 1008

(PC+WAP) Electrical Equipment Website Template; Mechanical Equipment Website Source Code – 1008 Practical Collection pbootcms Template

An electrical and mechanical equipment PbootCMS website template compatible with both PC and WAP devices. Features a professional industrial design style, ideal for showcasing electrical equipment, mechanical products, and industrial applications. Helps electrical and mechanical enterprises showcase their brands online and attract industrial customers. Template Display | Installation Instructions | Website Backend: /admin.php | Username: admin | Password: admin | Extraction Password: www.4s5.cn | Related Articles...
👁 54