Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

symfony 1.4 doctrine 1.2 - create userfriendly query/update

I have table in mysql:

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

in sql I do for example:

$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...

how to do this in Doctrine 1.2?

like image 310
clausix95 Avatar asked Dec 10 '25 10:12

clausix95


1 Answers

Try something like this:

$q = Doctrine_Query::create()
    ->update('TABLE')
    ->set($num, '?', $val)
    ->where('id = ?', $id)
    ->execute();
like image 52
Hubert Perron Avatar answered Dec 12 '25 00:12

Hubert Perron