在 Symfony 中使用 Doctrine 更新多个列 [英] Update multiple columns with Doctrine in Symfony

查看:18
本文介绍了在 Symfony 中使用 Doctrine 更新多个列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须更新 Symfony 中的多个列,但我无法找到解决方案...所以,我想这样做:

I have to update multiple columns in Symfony, but I can nowhere find the solution... So, I'd like to do it in this way:

$q = Doctrine_Query::create()
     ->update('WebusersTable q')
     ->set('q.login_name','?','John')
     ->where('q.webuser_id=?',1)
     ->execute();

好的,这行得通,但我必须用几列来做.我尝试了类似的方法,但它不起作用:

OK, that works, but I have to do it with several columns. I tried something like this, but it doesn't work:

$q = Doctrine_Query::create()
     ->update('WebusersTable q')
     ->set('q.login_name,q.name','?','kaka,pisa')
     ->where('q.webuser_id=?',1)
     ->execute();

推荐答案

试试:

$q = Doctrine_Query::create()
     ->update('WebusersTable q')
     ->set('q.login_name', 'John')
     ->set('q.name', 'Another value')
     ->where('q.webuser_id=?',1)
     ->execute();

这篇关于在 Symfony 中使用 Doctrine 更新多个列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆