add ($data);" method to obtain the primary key id of the newly added data."/> add ($data);" method to obtain the primary key id of the newly added data.">

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

How to get the modified id in thinkphp3.2

藏色散人
藏色散人Original
2022-12-05 10:25:411250browse

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);

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!

Statement:
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