


Detailed explanation of the steps to use Yii framework builder, update and delete
This time I will bring you the yii frameworkbuilder, update, deleteDetailed explanation of the steps to use, the precautions for using the yii framework builder, update, and deleteare Which ones, the following are practical cases, let’s take a look.
I encountered such a problem when writing a statement:
$connection = Yii::app()->db; $command = $connection->createCommand(); $operate_rst = 0; if(!empty($_POST['lid'])){ $operate_rst = $command->update('emg_landing', $landing_info, 'lid=:lid', array(':lid' => $_POST['lid'])); } else{ $operate_rst = $command->insert('emg_landing', $landing_info); } $connection->active = false; if($operate_rst > 0){ Functions:: return Ok('OK!'); } Functions::returnErrorJson();
Use $operate_rst to record the operation results. There is no problem in executing a new insert, but when updating, sometimes it will be displayed The operation failed. After checking for a long time, I couldn't find the reason. I had to go to the document
http://www.yiiframework.com/doc/api/1.1/CDbCommand#update-detail
and saw the return item:
{return} integer number of rows affected by the execution.
Sometimes the data may not have been changed but The update operation is triggered, so the number of changed rows at this time is 0, and the returned judgment enters the error code.
Similarly, the meaning of the return value of the delete() and insert() methods is also the number of affected rows, so delete and insert can determine whether the operation is successful based on whether the return value is greater than 0, but update operationNot necessarily. A return value of 0 may also indicate that the DB operation was successful.
I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!
Recommended reading:
PHP7 uses lib library case code analysis based on function method
How to make an addable function in PHP Classes for watermarking and generating thumbnails
The above is the detailed content of Detailed explanation of the steps to use Yii framework builder, update and delete. For more information, please follow other related articles on the PHP Chinese website!

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

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



Google Chrome is one of the most popular browsers in the world and many users prefer to use it as the default browser on their Windows PCs. Chrome offers a wide range of features that make the browsing experience enjoyable and effortless, and therefore, it remains one of the most trusted browsers. But just like any other browser, even Chrome has its own shortcomings, and it's equally prone to bugs and glitches when you need it most. One such error is Error Code 3: 0x80040154, which occurs while checking for Google Chrome updates. The error message reads "An error occurred while checking for updates. The update check failed to start (Error code 3: 0x80080005) or (Error

There are two keyboard delete keys: del (delete) key and backspace key. Backspace is also called the backspace key. This key can delete the text content in front of the cursor; and the delete key can delete characters, files and selected objects. Each time you press the del key, a character to the right of the cursor will be deleted, and the character to the right of the cursor will move one frame to the left; when one or more files/folders are selected, press the Del key to quickly delete; in some applications Select an object in the program and press the Del key to quickly delete the selected object.

The functions of the delete key are: 1. Delete characters; each time the delete key is pressed, a character to the right of the cursor will be deleted, and the character to the right of the cursor will move one frame to the left. 2. Delete files; when one or more files/folders are selected, press the Delete key to quickly delete them (move to the Recycle Bin for recovery). 3. Delete the selected object; select an object in some applications and press the Delete key to quickly delete the selected object.

If you are using Visual Studio Code (VSCode) and thinking about how to disable its automatic software updates and how to disable the automatic updates of its extensions, then read this article. If you don't use VSCode often, open the editor after a long period of time and want to enable automatic updates, this article will also guide you in doing so. Let us discuss in detail the different ways to enable or disable VSCode automatic updates. Table of Contents Method One: Use Settings to Enable/Disable VSCode Automatic Updates Step 1: Open VS Code and click the gear-shaped symbol in the lower left corner. Step 2: Click Settings in the list that appears. Step 3: Type update in the search bar and hit enter. Find Updates: Pattern 4

After several pre-releases, the KDE Plasma development team unveiled version 6.0 of its desktop environment for Linux and BSD systems on 28 February, using the Qt6 framework for the first time. KDE Plasma 6.1 now comes with a number of new features t

Control+Alt+Delete: "Mac" mode Ctrlaltdel is a common key combination used by Windows users to open Task Manager. They usually exit unwanted applications from the manager menu to free up some space on their computer. The Control+Alt+Delete Mac variant lets you open the Force Quit menu. If Mac users want to quit the program causing the problem or view open programs, they can interact with the menu to investigate further. How to perform ControlAltDelete on Mac? If you have any malfunctioning applications, you must use this key combination to

When we use the win10 system, we sometimes encounter situations where the computer becomes stuck. Then when we check the background process, we find that a Microsoftcompatibilitytelemetry process takes up a particularly high amount of resources. So what is going on? Users can try to uninstall the third-party protection software and then try a clean boot to operate. Let this site carefully introduce to users the solution to the high CPU usage of Microsoftcompatibilitytelemetry. Solution to the high CPU usage of Microsoftcompatibilitytelemetry Method 1: Try after uninstalling the third-party protection software

SQLUPDATE statement The Update statement is used to modify the data in the table. The syntax is as follows: UPDATE table name SET column name = new value WHERE column name = certain value "Person" table: LastNameFirstNameAddressCityGatesBillXuanwumen10BeijingWilsonChamps-Elysees Update a column in a certain row UPDATEPerson SETFirstName="Fred" WHERELastName="Wilson" Result: LastNa
