My DB looks like
Code: Select all
TABLE `prices`
id -> int -> auto increment - key
price -> int
city -> varchar
timestamp
Code: Select all
proc pa { nick host handle channel text } {
some basic checking
set sql "INSERT INTO prices VALUES(null, "
set text [mysqlescape $text]
append sql "'$text', "
append sql "'therightcity', "
append sql "'[clock seconds]')"
putloglev d * "Busy: executing $sql"
set result [mysqlexec $db_handle $sql]
What I want to achieve now, is that my tcl script updates the proper price for each city (based on the command input from a user) instead of adding a new DB entry.
Example:
3h00, prices are being reset, db record for city New York looks like 1 - 0 - NY - 0
User types !pny 1234
Script should Update the proper record in the mysql db and it should look like 1 - 1234 - NY - unixtimestamp.
And this is where i have troubles: I've changed the above 'insert statement' to and update statement, but without any luck.
The modified code I tried to use was:
Code: Select all
set sql "UPDATE prices SET (null, "
set text [mysqlescape $text]
append sql "'$text', "
append sql "'NY', "
append sql "'[clock seconds]') WHERE city ='NY'"
Thx in advance
FB