Platon Technologies
neprihlásený Prihlásiť Registrácia
SlovakEnglish
open source software development oslavujeme 10 rokov vývoja otvoreného softvéru! Štvrtok, 26. november 2026
O nás
Magazín
Otvorený softvér
CVS
Služby
Index  »  Projekty  »  phpMyEdit  »  Fórum  »  How to force trigger

phpMyEdit General     How to force trigger
Odoslať novú tému   Odpovedať na tému    
 
Atara.H     Založený: 23.07.2014   Príspevky: 11  
Príspevok Zaslal: 2016-10-31 11:29
Návrat hore  Odpovedať s citátom     

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     Založený: 10.02.2003   Príspevky: 1013   Bydlisko: Denver, Colorado (USA)
Príspevok Zaslal: 2016-11-01 14:46
Návrat hore  Odpovedať s citátom     

Post the code for the trigger script.

 
Atara.H     Založený: 23.07.2014   Príspevky: 11  
Príspevok Zaslal: 2016-11-02 10:35
Návrat hore  Odpovedať s citátom     

<?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     Založený: 10.02.2003   Príspevky: 1013   Bydlisko: Denver, Colorado (USA)
Príspevok Zaslal: 2016-11-02 18:35
Návrat hore  Odpovedať s citátom     

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     Založený: 23.07.2014   Príspevky: 11  
Príspevok Zaslal: 2016-11-03 12:47
Návrat hore  Odpovedať s citátom     

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     Založený: 10.02.2003   Príspevky: 1013   Bydlisko: Denver, Colorado (USA)
Príspevok Zaslal: 2016-11-03 18:29
Návrat hore  Odpovedať s citátom     

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

 
Odoslať novú tému   Odpovedať na tému    

Copyright © 2002-2006 Platon Group
Stránka používa redakčný systém Metafox
Na začiatok · Odkazový formulár · Prihláška
Upozorniť na chybu na PLATON.SK webstránke · Podmienky použitia · Ochrana osobných údajov