| Index
» Projekty
» phpMyEdit
» Fórum
» trigger insert before |
 |
kovacsp
Založený: 09.10.2003
Príspevky: 1
Zaslal: 2003-10-09 20:22
Návrat hore
Odpovedať s citátom
|
Hi,
A have a problem with the trigger feature.
I have a content management system using PHPMyEdit, which is really great!
I have a 'news' table with a field 'keyword'. I can post new articles into the admin, but I would like to check and modify(!) the 'keyword' field before the Mysql Insert.
The way I think it can work is using a .TIB file. It is okay, but I dont know what variable I have to modify, which one will be Inserted by the sql command.
Thanks in advance!
|
manamalkav
Založený: 11.11.2003
Príspevky: 8
Bydlisko: Florida, USA
Zaslal: 2003-11-17 15:09
Návrat hore
Odpovedať s citátom
|
Hi,
I had a similar requirement in one of my projects.
I thought that changing the 'newvals[]' array within the TIB/TUB trigger would do this ... but, it turns out that because the query (The insert/update sql statement) is completely constructed before the TIB/TUB is invoked, the changes that you make to newvals[] within the TIB/TUB will not change what actually goes into the table (The changelog file will hold the changed value though!)
The easiest option for you would be to use the TIA/TUA (After triggers) to run an update sql statement on the table (using the record number) and force your new value (Dirty method but works!).
Another option would be to make changes to the class file... Pretty convoluted.
Thanks
|
hbernard
Založený: 23.03.2003
Príspevky: 159
Bydlisko: FRANCE
Zaslal: 2003-11-17 17:28
Návrat hore
Odpovedať s citátom
|
I'm now pretty sure PME _must_ rebuild sql statement if triggers are used.
Waiting for this feature, you may simply put in your trigger this code :
| Kód: |
$newvals[$this->fds[$k]] = 'MY NEW VALUE';
$vals_quoted[$k] = addslashes($newvals[$this->fds[$k]]);
$vals_quoted[$k] = "'".$vals_quoted[$k]."'"; |
...where $k is the field number.
| manamalkav Napísal: |
Hi,
I had a similar requirement in one of my projects.
I thought that changing the 'newvals[]' array within the TIB/TUB trigger would do this ... but, it turns out that because the query (The insert/update sql statement) is completely constructed before the TIB/TUB is invoked, the changes that you make to newvals[] within the TIB/TUB will not change what actually goes into the table (The changelog file will hold the changed value though!)
The easiest option for you would be to use the TIA/TUA (After triggers) to run an update sql statement on the table (using the record number) and force your new value (Dirty method but works!).
Another option would be to make changes to the class file... Pretty convoluted.
Thanks |
|
|
Odoslať novú tému
Odpovedať na tému
|
|
|
|