thinkPHP查询方式小结_PHP
本文实例总结了thinkPHP查询方式。分享给大家供大家参考,具体如下:
一、普通查询方式
1. 使用字符串查询;
代码如下:
$m->where(' id=1 and name="roge" ')->find();
这种方法存在一个缺点,就是当数据表中的查询字段为字符串时,需要在字段值中加入引号。
2. 使用数组的方式(推荐使用)
$data['name']="adfa"; $data['id']=3; $data['_logic']="or"; //字段之间的逻辑关系,默认为and的关系 $m->where($data)->find();
二、表达式查询
EQ 等于;
NEQ 不等于;
GT 大于;
EGT 大于等于;
LT 小于;
ELT 小于等于;
LIKE 模糊查询;
$data['id']=array('gt',6); $data['name']=array('like','%as%'); //notlike //$data['name']=array('like',array('%as%','%ts'),'and'); 默认为or关系,如果用and需要明确指定 $m->where($data)->select(); //其他查询 between, not between (之间有空格),in,not between,
三、区间查询
$data['id']=array(array('gt',5),array('lt',10)); //默认生成的是and的关系 //$data['id']=array(array('lt',5),array('gt',10),'or') $data['name']=array(array('like','%d%'),array('like','%e%'),'gege','or'); $m->where($data)->select();
四、统计查询
count,max, min, avg, sum
代码如下:
$m->max('id')
五、SQL直接查询
$m=M(); $result=$m->query("select * from think_user where id>1") //query主要用于对数据进行读取 $result=$m->execute("insert into think_user(`name`) values ('dfd') "); //execute用于对数据进行写入
更多关于thinkPHP相关内容可查看本站专题:《ThinkPHP入门教程》及《ThinkPHP常用方法总结》
希望本文所述对大家基于thinkPHP框架的PHP程序设计有所帮助。

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

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



To run the ThinkPHP project, you need to: install Composer; use Composer to create the project; enter the project directory and execute php bin/console serve; visit http://localhost:8000 to view the welcome page.

Download the latest version of 12306 ticket booking app. It is a travel ticket purchasing software that everyone is very satisfied with. It is very convenient to go wherever you want. There are many ticket sources provided in the software. You only need to pass real-name authentication to purchase tickets online. All users You can easily buy travel tickets and air tickets and enjoy different discounts. You can also start booking reservations in advance to grab tickets. You can book hotels or special car transfers. With it, you can go where you want to go and buy tickets with one click. Traveling is simpler and more convenient, making everyone's travel experience more comfortable. Now the editor details it online Provides 12306 users with a way to view historical ticket purchase records. 1. Open Railway 12306, click My in the lower right corner, and click My Order 2. Click Paid on the order page. 3. On the paid page

How to check my academic qualifications on Xuexin.com? You can check your academic qualifications on Xuexin.com, but many users don’t know how to check their academic qualifications on Xuexin.com. Next, the editor brings you a graphic tutorial on how to check your academic qualifications on Xuexin.com. Interested users come and take a look! Xuexin.com usage tutorial: How to check your academic qualifications on Xuexin.com 1. Xuexin.com entrance: https://www.chsi.com.cn/ 2. Website query: Step 1: Click on the Xuexin.com address above to enter the homepage Click [Education Query]; Step 2: On the latest webpage, click [Query] as shown by the arrow in the figure below; Step 3: Then click [Login Academic Credit File] on the new page; Step 4: On the login page Enter the information and click [Login];

ThinkPHP has multiple versions designed for different PHP versions. Major versions include 3.2, 5.0, 5.1, and 6.0, while minor versions are used to fix bugs and provide new features. The latest stable version is ThinkPHP 6.0.16. When choosing a version, consider the PHP version, feature requirements, and community support. It is recommended to use the latest stable version for best performance and support.

Steps to run ThinkPHP Framework locally: Download and unzip ThinkPHP Framework to a local directory. Create a virtual host (optional) pointing to the ThinkPHP root directory. Configure database connection parameters. Start the web server. Initialize the ThinkPHP application. Access the ThinkPHP application URL and run it.

Performance comparison of Laravel and ThinkPHP frameworks: ThinkPHP generally performs better than Laravel, focusing on optimization and caching. Laravel performs well, but for complex applications, ThinkPHP may be a better fit.

ThinkPHP installation steps: Prepare PHP, Composer, and MySQL environments. Create projects using Composer. Install the ThinkPHP framework and dependencies. Configure database connection. Generate application code. Launch the application and visit http://localhost:8000.

If you want to check the activation date using an Apple mobile phone, the best way is to check it through the serial number in the mobile phone. You can also check it by visiting Apple's official website, connecting it to a computer, and downloading third-party software to check it. How to check the activation date of Apple mobile phone Answer: Serial number query, Apple official website query, computer query, third-party software query 1. The best way for users is to know the serial number of their mobile phone. You can see the serial number by opening Settings, General, About This Machine. . 2. Using the serial number, you can not only know the activation date of your mobile phone, but also check the mobile phone version, mobile phone origin, mobile phone factory date, etc. 3. Users visit Apple's official website to find technical support, find the service and repair column at the bottom of the page, and check the iPhone activation information there. 4. User
