yii2


Yii2 update with multiple conditions


$this->localdb->createCommand()
->update(
$this->MYTable,
[
'name' => $el['new'],
'data' => $el['data'],
],
[
'userId', $this->user,
'product_id', $this->productId,
'name', $el['old'],
'created', $el['date'],
'category', $el['cat'],
]
);
I tried to use the following command to update a row using multiple where conditions, but it doesn't work for some reason. The documentation doesn't seem to cover this case and doesn't seem to be updated, because the update() method seems to match the updateAll method instead of the update method for some reason (maybe it was updated?). So I was wondering what was the correct way to do this.
You have a syntax error. Try following:
$this->localdb->createCommand()
->update(
$this->MYTable,
[
'name' => $el['new'],
'data' => $el['data'],
],
[
'userId' => $this->user,
'product_id' => $this->productId,
'name' => $el['old'],
'created' => $el['date'],
'category' => $el['cat'],
]
);

Related Links

How display Yii2 pagination in GridView widget on and top and bottom part of table?
How to print converted SQL query from yii2 query
Calculate from 3 inputfield in dynamic form yii2
Create pdf in Yii2 using mpdf extension: controller - view code
Kartik file input Post as file name, not as file object
Add class to bootstrap textbox - yii2
Set enablePushState = false on specific urls inside Pjax container (Yii2)
Yii2 select dropdown text
Redirecting on if condition in yii2
Using from another table for radioList's select options
How do I setup the reset password function on Yii2?
i want to use a toggle switch for active inactive status, i want to use in yii2 curd index page, i have added a widget toggle
How to save current user_id to database (YII2)
How to add whole directory to js section in asset bundle yii2
Yii2 - How can I add a search in Dropdownlist Widget
Show only 5 item in yii2 List view

Categories

HOME
ibm-bluemix
compiler-construction
pdf
wso2-am
clips
reflection
push-notification
google-api-php-client
hashmap
android-4.4-kitkat
adb
at-command
analysis
paw-app
ckeditor
maude-system
tomcat6
decomposition
django-simple-history
ghc
tostring
ef-migrations
jsdoc
reactcsstransitiongroup
tar
android-widget
sparse-matrix
jspm
fabric8
typed.js
caret
commit
subset-sum
http-referer
mmenu
mapdb
jquery-bootgrid
web-mining
gesture
neuroscience
squib
sas-visual-analytics
turbogears
sas-jmp
skeleton-css-boilerplate
apache-fop
pubmed
lowpass-filter
google-perftools
epson
jspdf-autotable
sonarlint-vs
gnome-shell-extensions
medium.com
color-picker
trash
skobbler-maps
lttng
blackberry-10
hill-climbing
iad
rtbkit
lib.web.mvc
cannon.js
wireshark-dissector
nsight
javax.mail
gui-test-framework
java.util.concurrent
codeigniter-routing
device-manager
android-radiobutton
marmalade
seaside
balanced-payments
message-driven-bean
pyhdf
access-rights
coverflow
dotnetnuke-5
sqlperformance
comaddin
angularjs-controller
sublist
broken-links
word-processor
getmessage
chrono
amazon-appstore
coredump
xdomainrequest
table-footer
file-comparison
exchange-server-2003
yagni
premature-optimization
scripting-languages
ugc
paul-graham
caching-application-block

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App