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 internal server error when uploaded to live server. What is wrong?
Making Yii2 as SSO server
Yii2, how to use bootstrap less in yii2 project?
Handle runtime exception in yii2 in rbac
How to get list of controller in frontend from backend in Yii2 Advanced Template?
How to insert same data record to multiple table on Yii2
Yii2 radio button validation is not working
keep filters/sort status when changing page and go back
How to open in a new window for a submit button?
How to add google-chart correctly in Yii2?
Multiple relations in Yii 2.0 ActiveRecord Model
controller action with different render view base on contest page
Will mPDF show font Awesome Icons?
yii2 disable access by right part of routing rule
Add Logo & Title to NavBar (Yii2)
Yii2 access to actions in new controllers

Categories

HOME
yii2
youtube-dl
packages
survey
callback
disassembler
pivotal-cloud-foundry
networkx
pheatmap
basic
ssl-client-authentication
adobe-analytics
user-input
flask-wtforms
systemc
highlight.js
ef-migrations
finite-automata
google-cloud-speech
textfield
visjs
buck
saas
windows-server-2000
windowbuilder
file-rename
socialengine
iframe-resizer
oracle-fusion-middleware
contact-form
overriding
wixsharp
xcode-extension
hockeyapp
hue
opshub
azure-ml
ncalc
dynamic-reports
texmaker
s
cubic-spline
wso2carbon
jedis
pango
prolog-setof
return-value
kbuild
libusb-win32
imanage
jspdf-autotable
lync-client-sdk
topbeat
messenger
google-feed-api
gridview-sorting
jwplayer7
nsviewcontroller
rvest
pyke
energy
intel-fortran
browser-bugs
microbenchmark
bridge.net
network-interface
angularjs-ng-click
winddk
neolane
openexr
jboss-weld
c18
dataservice
cassini-dev
quickdialog
runas
propertyeditor
errai
viewswitcher
adk
hirefire
horizontal-accordion
revisions
nintendo-ds
adrotator
avatar
zend-decorators
thread-local-storage
rtml

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile