Get the App
SLTechnology News&Howtos  ›  Development  › 

What are the data creation mechanisms of create

Shulou Source: shulou.com Published: 2022-06-02 11:26:27 10月02日 Update

This article mainly shows you "what is the data mechanism for creating create", which is easy to understand and well-organized. I hope it can help you solve your doubts. Let me lead you to study and learn this article "what is the data mechanism for creating create".

There are three data creation mechanisms for create:

1. Create data directly from the array

$data ['name'] =' ThinkPHP'; $data ['email'] =' ThinkPHP@gmail.com'; $User- > create ($data)

2. Create data from objects

$User = stdClass (); $User- > name = 'ThinkPHP'; $User- > email =' ThinkPHP@gmail.com'; $Member = M ("Member"); $Member- > create ($User)

3. Validate the form, and then create the data

$User = M ("User"); / / instantiate the User object / / create the data object if ($User- > create ()) based on the POST data submitted by the form {$result = $User- > add (); / / write the data to the database if ($result) {/ / if the primary key is auto-growing, the return value is the latest inserted value $insertId = $result }} these are all the contents of the article "what are the data mechanisms for creating create". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Data mechanism content objects articles forms learning help success examples that is databases arrays easy to understand more organization knowledge editing industry information Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn OPPO Reno Microsoft Redmi Shulou Tech Info