[英]symfony 1.4 doctrine 1.2 - create userfriendly query/update
I have table in mysql:我在 mysql 中有表:
id | num1 | num2| num 3| num3| num5|
1 | 6 | 3 | 4 | 2 | 1 |
in sql I do for example:在 sql 我做例如:
$num = num2;
$val = 2;
$id = 2;
$sql = "update TABLE set '$num'='$val' where id='$id'";
mysql_query( $sql);
I can do with $val
and $id
, but I have a problem with $num
...我可以使用$val
和$id
,但我遇到了$num
的问题......
how to do this in Doctrine 1.2?如何在 Doctrine 1.2 中做到这一点?
Try something like this:尝试这样的事情:
$q = Doctrine_Query::create()
->update('TABLE')
->set($num, '?', $val)
->where('id = ?', $id)
->execute();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.