Home > PHP Framework > ThinkPHP > How to get the modified id in thinkphp3.2

How to get the modified id in thinkphp3.2

藏色散人
Release: 2022-12-05 10:25:41
Original
1283 people have browsed it

thinkphp3.2 Method to obtain the modified id: 1. Open the corresponding tp file; 2. Instantiate the User object through "$User = D("User");"; 3. Through "$insert = $User->add($data);" to get the primary key id of the new data.

How to get the modified id in thinkphp3.2

#The operating environment of this tutorial: Windows 7 system, thinkphp version 3.2, Dell G3 computer.

How to get the modified id in thinkphp3.2?

thinkphp3.2.3 Get the primary key id of newly added data

tp3 itself inserts data and returns its primary key id value

eg:

$User = D("User"); // 实例化User对象
        $data['username'] = $userinfo['nickname'];
        $data['tel'] = $userinfo['province'];
        $data['portrait'] = $userinfo['figureurl_qq_2'];
        $data['time'] = time();
        $insert = $User->add($data);
Copy after login

Print $insert is the primary key value

Recommended learning: "thinkPHP Video Tutorial"

The above is the detailed content of How to get the modified id in thinkphp3.2. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template