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

phpMyEdit General     Delete trigger help please.
Odoslať novú tému   Odpovedať na tému    
 
Hobb3s     Založený: 06.06.2007   Príspevky: 6  
Príspevok Zaslal: 2007-10-09 19:24
Návrat hore  Odpovedať s citátom     

Hello, I've been attempting to get a delete trigger working, unsuccessfully and I've run out of ideas. I'm just not certain what I'm missing or where the error is. When I ask it to delete something I don't get any errors, it just goes back to displaying the database. The Filtering works properly for entries that I manually enter 1 for the deleted field.
TIA.

Here's what I have added to my configuration:
Kód:

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

$opts['triggers']['delete']['before'] = 'categories.TDB.inc';


And then to the file I specified categories.TDB.inc the following:

Kód:
<?php
$query2 = sprintf('UPDATE %s SET deleted = "1" WHERE %s = "%s"',
   $this->tb, $this->key, $oldvals[$this->key]);
if($this->MyQuery($query2)){
   return false;
}else{
   echo "\n".'<p>'.mysql_error().'</p>';
   echo "\n".'<a href="javascript:history.go(-1)"
      onmouseover="self.status=document.referrer;return true">Go Back</a>';
   exit;
}
?>
[/code]

 
michal     Založený: 17.06.2003   Príspevky: 537   Bydlisko: Slovakia
Príspevok Zaslal: 2007-10-10 10:11
Návrat hore  Odpovedať s citátom     

if your trigger succeded, you should return true (not false).

also, the two filters overvrite each other (the second one overwrites the first one).

 
Hobb3s     Založený: 06.06.2007   Príspevky: 6  
Príspevok Zaslal: 2007-10-11 13:47
Návrat hore  Odpovedať s citátom     

I figured the filters were probably doing the exact same thing.

If I return true though, it deletes the database entry, which is contrary to the goal of keeping all the data and pretending it is deleted by filtering.

 
Hobb3s     Založený: 06.06.2007   Príspevky: 6  
Príspevok Zaslal: 2007-10-11 14:16
Návrat hore  Odpovedať s citátom     

I've half figured it out. But now it it only takes the one with id 0, it seems that %d returns a 0 regarless of the record I choose. I don't entirely understand what the %s and %d represent. TIA.

Here is the code.
Kód:
$query2 = sprintf('UPDATE %s SET deleted = 1 WHERE id = %d',
   $this->tb, $newvals['id']);
if($this->MyQuery($query2)){
   return false;
}else{
   echo "\n".'<p>'.mysql_error().'</p>';
   echo "\n".'<a href="javascript:history.go(-1)"
      onmouseover="self.status=document.referrer;return true">Go Back</a>';
   exit;
}


 
Hobb3s     Založený: 06.06.2007   Príspevky: 6  
Príspevok Zaslal: 2007-10-11 19:10
Návrat hore  Odpovedať s citátom     

Ok, at last it works. A few mods to the query.

Kód:

$query2 = sprintf('UPDATE %s SET deleted = 1 WHERE %s = "%s"',
$this->tb, $this->key, $oldvals[$this->key]);
if($this->MyQuery($query2)){
   return false;
}else{
   echo "\n".'<p>'.mysql_error().'</p>';
   echo "\n".'<a href="javascript:history.go(-1)"
      onmouseover="self.status=document.referrer;return true">Go Back</a>';
   exit;
}


That seems to work perfectly for my purpose. I hope this helps someone else.

 
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