


Detailed introduction to common expression examples in ThinkPHP Where conditions
The following editor will bring you a ThinkPHP Examples of expressions commonly used in Where conditions (detailed explanation). The editor thinks it’s pretty good, so I’ll share it with you now and give it as a reference. Let’s follow the editor and take a look.
Where conditional expression format is:
$map['字段名'] = array('表达式', '操作条件');
where $map is an ordinary ArrayVariable can be named according to your own needs. The expression in the above format is actually the meaning of operator:
TP Operator | SQL Operator | Example | ActualQueryCondition |
---|---|---|---|
eq | = | $map['id'] = array('eq',100); | Equivalent to: $ map['id'] = 100; |
neq | != | $map['id'] = array('neq', 100); | id != 100 |
gt | > | $map['id'] = array( 'gt',100); | id > 100 |
egt | >= | $map['id '] = array('egt',100); | id >= 100 |
lt | $map['id'] = array('lt',100); | id | |
$map['id'] = array('elt',100); | id | ||
like | $map = array('like','Admin%'); | username like 'Admin%' | |
between and | $map['id'] = array('between','1,8'); | id BETWEEN 1 AND 8 | |
not between and | $map['id'] = array('not between','1,8' ); | id NOT BETWEEN 1 AND 8 | |
in | $map['id'] = array( 'in','1,5,8'); | id in(1,5,8) | |
not in | $map['id'] = array('not in','1,5,8'); | id not in(1,5,8) | |
and | $map['id'] = array(array('gt',1),array('lt', 10)); | (id > 1) AND (id | |
or | $ map['id'] = array(array('gt',3),array('lt',10), 'or'); | (id > 3) OR (id | |
xor | When only one of the two inputs is true, the result is true, otherwise it is false, example slightly. | 1 xor 1 = 0 | |
Comprehensive expression | $map['id'] = array(' exp','in(1,3,8)'); | $map['id'] = array('in','1,3,8'); |
Supplementary instructions
• Like SQL, ThinkPHP operators are not case-sensitive, and eq is the same as EQ.
• between and in conditions support string or array, that is, the following two writing methods are equivalent:
$map['id'] = array('not in','1,5,8'); $map['id'] = array('not in',array('1','5','8'));
exp expression
exp in the above table is not an operator, but a comprehensive expression to support more complex condition settings. The operating conditions of exp will not be treated as strings, and any syntax supported by SQL can be used, includingusing functions and field names.
exp is not only used for where conditions, but also for data update, such as:
$Dao = M("Article"); //构建 save 的数据数组,文章点击数+1 $data['id'] = 10; $data['counter'] = array('exp','counter+1'); //根据条件保存修改的数据 $User->save($data);
The above is the detailed content of Detailed introduction to common expression examples in ThinkPHP Where conditions. For more information, please follow other related articles on the PHP Chinese website!

Thedifferencebetweenunset()andsession_destroy()isthatunset()clearsspecificsessionvariableswhilekeepingthesessionactive,whereassession_destroy()terminatestheentiresession.1)Useunset()toremovespecificsessionvariableswithoutaffectingthesession'soveralls

Stickysessionsensureuserrequestsareroutedtothesameserverforsessiondataconsistency.1)SessionIdentificationassignsuserstoserversusingcookiesorURLmodifications.2)ConsistentRoutingdirectssubsequentrequeststothesameserver.3)LoadBalancingdistributesnewuser

PHPoffersvarioussessionsavehandlers:1)Files:Default,simplebutmaybottleneckonhigh-trafficsites.2)Memcached:High-performance,idealforspeed-criticalapplications.3)Redis:SimilartoMemcached,withaddedpersistence.4)Databases:Offerscontrol,usefulforintegrati

Session in PHP is a mechanism for saving user data on the server side to maintain state between multiple requests. Specifically, 1) the session is started by the session_start() function, and data is stored and read through the $_SESSION super global array; 2) the session data is stored in the server's temporary files by default, but can be optimized through database or memory storage; 3) the session can be used to realize user login status tracking and shopping cart management functions; 4) Pay attention to the secure transmission and performance optimization of the session to ensure the security and efficiency of the application.

PHPsessionsstartwithsession_start(),whichgeneratesauniqueIDandcreatesaserverfile;theypersistacrossrequestsandcanbemanuallyendedwithsession_destroy().1)Sessionsbeginwhensession_start()iscalled,creatingauniqueIDandserverfile.2)Theycontinueasdataisloade

Absolute session timeout starts at the time of session creation, while an idle session timeout starts at the time of user's no operation. Absolute session timeout is suitable for scenarios where strict control of the session life cycle is required, such as financial applications; idle session timeout is suitable for applications that want users to keep their session active for a long time, such as social media.

The server session failure can be solved through the following steps: 1. Check the server configuration to ensure that the session is set correctly. 2. Verify client cookies, confirm that the browser supports it and send it correctly. 3. Check session storage services, such as Redis, to ensure that they are running normally. 4. Review the application code to ensure the correct session logic. Through these steps, conversation problems can be effectively diagnosed and repaired and user experience can be improved.

session_start()iscrucialinPHPformanagingusersessions.1)Itinitiatesanewsessionifnoneexists,2)resumesanexistingsession,and3)setsasessioncookieforcontinuityacrossrequests,enablingapplicationslikeuserauthenticationandpersonalizedcontent.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Linux new version
SublimeText3 Linux latest version

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.
