data['car'].", // should add value to excisting valuebrt=brt+".$form->data['brt'].", // should add value to excisting valuehs={ $max: {hs:[".$form->data['hs']."]} }, // should add value if value is highergesp=gesp+".$form->data['gesp']." // should add value to excisting value WHEREp_id=".$form->data['p_id']."''; $db->setQuery$sql);$result = $db->query();?> What am i doing wrong here??Regards TheonPS. In a second DBSAVE this all has to be INSERTED in ANOTHER db on same server. In this db it should UPDATE .At the moment i only use the Updating DBSave for testing"> DB insert instead of update - Forums

Forums

DB insert instead of update

Theon 11 Feb, 2015
Hai,

When i try to update my db records with a DBSave action it inserts instead of updating excisting record.
[attachment=0]example.jpg[/attachment]

I use as 'Update conditions';

<?php
$db = JFactory::getDbo();
$sql = "UPDATE band_Uitslagen_VR SET
poule=".$form->data['poule'].",                   //should insert if not excists or replace if excists
naam=".$form->data['naam'].",                  //should insert if not excists or replace if excists
tm=".$form->data['tm'].",                            //should insert if not excists or replace if excists
p_id=".$form->data['p_id'].",                      //should insert if not excists or replace if excists
car=car+".$form->data['car'].",                  // should add value to excisting value
brt=brt+".$form->data['brt'].",                    // should add value to excisting value
hs={ $max: {hs:[".$form->data['hs']."]} },   // should add value if value is higher
gesp=gesp+".$form->data['gesp']."          // should add value to excisting value

 WHERE
p_id=".$form->data['p_id']."'';                  
$db->setQuery$sql);
$result = $db->query();
?>
What am i doing wrong here??

Regards Theon

PS. In a second DBSAVE this all has to be INSERTED in ANOTHER db on same server.
In this db it should UPDATE .
At the moment i only use the Updating DBSave for testing
GreyHead 12 Feb, 2015
Hi Theon,

The Update conditions box is badly named. Basically it just handles the WHERE part of your MySQL query. It does not take the whole query as you have here. Please see this FAQ

The ChronoForms DB Save action doesn't support the `value` + 'new_value' method. You can do this by reading the existing record, updating values in a Custom Code action and then re-saving it.

You could also use a Custom Code action for the whole of the MySQL query as you have it - that might be the simplest solution. But note that any string values need to be quoted for the query to work.

Bob

PS In Joomla! 3 you need to use $db->execute() instead of $db->query() . . .
This topic is locked and no more replies can be posted.