Run PHP query after CSV Export

momentis 16 Jan, 2014
Chronoforms: Latest v4 version
Joomla: 3.2.1

I have a small form that will export data from a table in CSV format. The table contains a flag field to indicate if the record has been downloaded so that a user will only get now records (ones that were not previously downloaded) when they download again.

The export is running perfectly. However, I am trying to use the following in a Custom Code action following the CSV Export action:

<?php
$db =& JFactory::getDBO();
$query = "UPDATE `#__registration_cfna_2014` SET `reg_down`= '1'";
$db->setQuery($query);
$db->query();
?>


I know this works correctly, as I have tested it running prior to the export. I also tried placing this code in the OnSuccess event in the CSV Export action, which do not work either.

Here is the Events layout:
[attachment=0]csv-export.jpg[/attachment]

Thanks!
Rick
GreyHead 17 Jan, 2014
Hi Rick,

How are you handling the CSV download? If it is immediate then it hi-jacks the form process and you can't run anything after that. Switch to adding a link in the Thank you page and the extra code should run OK.

Note: $db->query() is now deprecated; switch to $db->execute() instead to avoid future problems. See here.

Bob
This topic is locked and no more replies can be posted.