Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Wednesday, November 11, 2026
About Us
Magazine
Open Source
CVS
Services
Index  »  Projects  »  phpMyEdit  »  Forum  »  How to force trigger

phpMyEdit General     How to force trigger
Post new topic   Reply to topic    
 
Atara.H     Joined: 23 Jul 2014   Posts: 11  
Post Posted: 2016-10-31 11:29
Back to top  Reply with quote     

I added trigger before deleting -

$opts['triggers']['delete']['pre'] = 'adm_faq.php.trg.inc.php';

The icon button on the record line do consider the trigger.

The main-delete-button (bellow all rows), on View-Mode do consider the trigger.


but if i return to view-mode, after trying to delete + the trigger fails the delete, now, when clicking the main-delete-button, the record is deleted, without considering the trigger, and without option for "Delete or Cancel"

How can I force the main "Delete" button, after failed-delete to also consider the trigger?

 
doug     Joined: 10 Feb 2003   Posts: 1013   Location: Denver, Colorado (USA)
Post Posted: 2016-11-01 14:46
Back to top  Reply with quote     

Post the code for the trigger script.

 
Atara.H     Joined: 23 Jul 2014   Posts: 11  
Post Posted: 2016-11-02 10:35
Back to top  Reply with quote     

<?php
$trig_query= sprintf("select * from faq_table where faq_id = %d", $this->rec);
$trig_result = $this->myquery($trig_query);
$res1 = $this->sql_num_rows(); // $res1 = mysql_num_rows($trig_result);

if ($res1>0)
{
echo "L'objet est deja utilise, imposssible d'effacer";
$r = false;
}
else
{
$r = true;
}

$isOk = $this->sql_free_result_pdo(); // @mysql_free_result($trig_result);
return $r;

?>

 
doug     Joined: 10 Feb 2003   Posts: 1013   Location: Denver, Colorado (USA)
Post Posted: 2016-11-02 18:35
Back to top  Reply with quote     

I do not fully understand the problem. Consider the following information and/or example and maybe you will locate a solution.

I think perhaps
$opts['triggers']['delete']['pre'] = 'adm_faq.php.trg.inc.php';
should instead be
$opts['triggers']['delete']['before'] = 'adm_faq.php.trg.inc.php';

If you trigger fails to execute the desired result, add code to die() with a message that helps you determine the problem.

My methods are different.

I always use a column named `deleted` tinyint(1) indexed default '0' and a trigger to change the value to '1' if the record is deleted. Then, in List mode, I use 'filters' to only display records having `deleted` equal to 0. This way, if a user deletes a record by accident, I can use phpMyAdmin to un-delete the record. I am told it is better to flag records as deleted than to actually delete records, thus the `deleted` field is something I almost always use, with the following trigger.

In the script:

$opts['filters'] = 'PMEtable0.deleted = "0"';

$opts['triggers']['delete']['before'] = 'inc/triggers/mark_as_deleted.TDB.php';

In the trigger file /inc/triggers/mark_as_deleted.TDB.php:

$query2 = sprintf('UPDATE %s SET `deleted` = "1" WHERE `%s` = "%s" LIMIT 1', $this->tb, $this->key, $this->rec);

 
Atara.H     Joined: 23 Jul 2014   Posts: 11  
Post Posted: 2016-11-03 12:47
Back to top  Reply with quote     

the problem is the delete button in the record line does not behave the same as the delete button a the bottom of all records,
this happens only after the first try to delete (from both delete buttons) fails because of the trigger.

in the 2nd try to delete -
the delete-record-button do test the trigger (and does not delete)
but the bottom-delete-button does not test the trigger (and do delete the selected record).

we might adapt logic from your code, thanks

 
doug     Joined: 10 Feb 2003   Posts: 1013   Location: Denver, Colorado (USA)
Post Posted: 2016-11-03 18:29
Back to top  Reply with quote     

echo the $_REQUEST variables, note PME_sys_operation and its value on different buttons

 
Post new topic   Reply to topic    

Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top · Feedback form · Application form
Report bug on PLATON.SK website · Terms of use · Privacy policy