Home » Database » DB_QueryTool » Bug #8129
how to build a update query as "set field=field+1" ?
Details
| Request #8129 | how to build a update query as "set field=field+1" ? |
|---|---|
| Submitted | 2006-07-06 15:01 UTC |
| From | tim1020 at 126 dot com |
| Assigned | quipo |
| Status | Closed |
| Package | DB_QueryTool |
| PHP Version | 4.4.0 |
| OS | winxp |
| Roadmaps | (Not assigned) |
Comments
[2006-07-06 15:01 UTC] tim1020 at 126 dot com
Description:
------------
if i want to build a query like this:
update tableName set colName = colName+1 where id=xxx
how to do?
Test script:
---------------
$data['id'] = 22;
$data['reads'] = "reads+1";
$this -> update($data);
Expected result:
----------------
update xx set id=22, reads=reads+1 where id=22
Actual result:
--------------
UPDATE xx SET id=22,reads='reads+' WHERE id=22
[2006-07-07 06:00 UTC] tim1020 at 126 dot com
I do this with $this -> setOption('raw', true),It' OK!
But an other trouble is:
if i want to quote other cols,like this:
UPDATE book SET price=price+1,desc='i\'m a \'phper\''
how can i do ? i want the DB_QueryTool can quote the desc but not price.
does it ?
[2006-07-07 06:12 UTC] tim1020 at 126 dot com
use $this -> db -> quoteSmart() by manual can do this
I advise that add a second params in update method, refers to which field(s) are not need to quote