update field with save form

guiogonza

New Member
I am grateful for the person who can help me with this, read in various forums and documentation but I can't make it work.

* I have a list and form called sales, I need that when I save the sales form the status field = 1 of another list called "raffle number" is updated, where the field "sales__number_rffle" = "nro_rifa__rifa"
 

Attachments

  • elementos.png
    elementos.png
    66.3 KB · Views: 92
  • form ventas.png
    form ventas.png
    16.2 KB · Views: 87
  • nro rifa.png
    nro rifa.png
    41.3 KB · Views: 79
Troester thanks for your help, with the complement I can enter the data in the other table but I don't know where to place the condition where the raffle_number = raffle of the other table, I appreciate the help you can give me and attached images.
 

Attachments

  • anotacion1.png
    anotacion1.png
    13.5 KB · Views: 67
  • anotacion2.png
    anotacion2.png
    28.5 KB · Views: 64
thanks for answer, it is correct toester I can insert new data in another table, but I need to update the table in the status field.
where table1.nro_rifa = form.rifa
 
troester im try wit this code but it does not work, can you help me what can be wrong

// Get the db object
$db = JFactory::getDbo();

// Build the query ? Tables names = CASE SENSITIVE
$query = $db->getQuery(true);

$query
-> update('nro rifa as nr')
-> join('ventas as v ON v.numero_rifa = nr.rifa')
-> set('nr.estado = 1')
-> where('nr.rifa = v.numero_rifa');

$db->setQuery($query);
$db->execute();


im run in phpmyadmin and work fine this
update nro_rifa as nr
JOIN ventas as v on v.numero_rifa = nr.rifa
set nr.estado = 1
where nr.rifa = v.numero_rifa
 
this erro shorw

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'as nr VENTAS AS V ON V.NUMERO_RIFA = NR.RIFA JOIN SET nr.estado = 1 WHERE nr.ri' at line 1
 
This is nothing related to Fabrik but

You missed the join type in the 1st param (Example: -> join('INNER','contactsstatus AS s ON s.Status = \'New\'') )
so e.g. ->join('LEFT',....

in update('nro rifa as nr') there seems a _ missing in your table name
 
thank for your help troester, now working, exactly the inner one was missing


$db = JFactory::getDbo();
$query = $db->getQuery(true);

$query
-> update('nro_rifa')
-> join('inner','ventas ON nro_rifa.rifa = ventas.numero_rifa')
-> set('estado = 1');

$db->setQuery($query);
$db->execute();
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top