2

我在mysql中有表:

id | num1 | num2| num 3| num3| num5|
1  | 6    | 3   | 4    | 2   | 1   |

在 sql 我做例如:

$num = num2; 
$val = 2;
$id  = 2;

$sql = "update TABLE set '$num'='$val' where id='$id'";
mysql_query( $sql);

我可以用$valand做$id,但我有一个问题$num......

如何在 Doctrine 1.2 中做到这一点?

4

1 回答 1

11

尝试这样的事情:

$q = Doctrine_Query::create()
    ->update('TABLE')
    ->set($num, '?', $val)
    ->where('id = ?', $id)
    ->execute();
于 2011-06-05T21:54:41.697 回答