[TYPO3-dev] Update query with increment
Steffen Kamper
steffen at sk-typo3.de
Sun Dec 30 14:54:59 CET 2007
Hi,
a while ago i thought that it is not possible to do a query like
UPDATE tx_counter SET counter=counter+1
with the TYPO3 DBwrapper-function. I remember i asked here in the list for
that, and because of no answer with the right usage i looked again to the
wrapper class, and it is possible.
Here is the solution:
$res = $GLOBALS['TYPO3_DB']->exec_UPDATEquery(
'tx_counter',
'',
array('counter' => 'counter + 1'),
array('counter')
);
Important is the last parameter $no_quote_fields (default is false).
Expected is an array with the fields without quoting, in this case the field
counter.
I hope this helps some of you creating update queries with fieldnames in
values.
vg Steffen
More information about the TYPO3-dev
mailing list