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

Yii2 HTML purifier
Yii2 pjax & NavBar - links not working
Yii2 Multi-Tenant Architecture - Choose correct database
Send mail on actionCreate
Is it possible to reference an existing ActiveRecord model from the classes generated with Gii?
Yii2 Rbac not able to add new roles
Insert checked rows from a gridview to a table in yii2
how to track changes of relation between two models in yii2
Yii2 get value before save in model
How to prevent malicious file upload?
How can i access Active Record fields in yii2 framework?
Send message over SMTP using Swiftmailer and Yii2
Yii2 Api user validation with query string
Yii2 attempts to re-apply old migration files
Set Dropdown list width in yii2
Yii2 api username password validation

Categories

HOME
multithreading
bluetooth
date
homebrew
relative-path
malloc
frameworks
jxls
enterprise-library-5
django-imagekit
gorm
fancybox-3
wheelnav.js
nstableview
sms-gateway
oxyplot
xlsxwriter
ehcache
pass-by-reference
vlsi
react-css-modules
traffic
assistant
sql-server-2012-express
socialengine
frame
titanium-mobile
siesta-swift
copying
mozilla
wixsharp
overlap
lto
neuroscience
angularjs-factory
ensembles
grid.mvc
qcombobox
menuitem
promela
mu
git-diff
spring-cache
redundancy
color-picker
home-directory
fputcsv
persist
ubuntu-10.04
qcustomplot
master-slave
whois
tform
associative-array
iad
xna-4.0
tmuxinator
citrus-pay
drawbitmap
0xdbe
interrupted-exception
bridge.net
oxwall
gui-test-framework
device-manager
terminfo
android-radiobutton
aapt
dml
valueconverter
comexception
undefined-reference
message-driven-bean
aqtime
tidy
apc
flashvars
robotics-studio
trusted
funscript
ticoredatasync
qtkit
ohm
blackberry-playbook
locate
cxxtest
infrastructure
mirah
iweb
backcolor
sector
.net-1.0
ntvdm.exe

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App