| Index
» Projekty
» phpMyEdit
» Fórum
» How to add new data sets with correct FK in filtered views? |
 |
Jochen
Založený: 22.10.2004
Príspevky: 7
Zaslal: 2004-10-22 14:30
Návrat hore
Odpovedať s citátom
|
Hi there,
I like phpMyEdit as editor for stand alone tables very much. But how to use it with master detail tables?
Situation:
A master table contains persons, each identified with an id. Another table contains data per person, e.g. tasks. In the detail (task) table a field FK (foreign key) exists which contains the id of the person the task belongs to.
Every person is allowed to view and edit own tasks (works with filters pretty nice).
But every person is allowed to add new tasks, too. How must phpMyEdit be configured to fill that FK field correctly? I'd guess somehow using triggers. Right? But how?
I'd think that this isn't an unusual case - is there an example or a tutorial about that? Would make sense in my opinion.
Thanks,
Jochen
|
michal
Založený: 17.06.2003
Príspevky: 537
Bydlisko: Slovakia
Zaslal: 2004-10-22 14:48
Návrat hore
Odpovedať s citátom
|
yes, it's trigger insert before, a very short one:
| Kód: |
<?php
$newvals['owner'] = current_user_id()
?>
|
you need cvs version of pme for this.
|
Jochen
Založený: 22.10.2004
Príspevky: 7
Zaslal: 2004-10-22 15:24
Návrat hore
Odpovedať s citátom
|
Hey, great response time:o)
| michal Napísal: |
yes, it's trigger insert before, a very short one
| Kód: |
<?php
$newvals['owner'] = current_user_id()
?>
|
|
I'll try that at the weekend (must get cvs version first...) I have read that in the docs before but to me it isn't clear if that would work with fields that are not displayed? Those id fields are of course not shown to the user... Does the $newvals array contain all fields of the table? And the $oldvals, too?
| michal Napísal: |
| you need cvs version of pme for this. |
Why? I read 5.4 is stable and http://opensource.platon.sk/projects/doc.php/phpMyEdit/html/configuration.triggers.html (belongs to it) talks about triggers.
I would clearly prefer a defined stable version (no time to update my version every two days with the cvs).
Edit: I just tried the trigger with the V5.4 - no complaints but wrong (default) ID. And I did a quick look at http://opensource.platon.sk/cvs/cvs.php/phpMyEdit/ - couldn't notice a file newer than V5.4. So what?
Thanks,
Jochen
|
michal
Založený: 17.06.2003
Príspevky: 537
Bydlisko: Slovakia
Zaslal: 2004-10-22 18:55
Návrat hore
Odpovedať s citátom
|
the problem with the stable version is that changes in $newvals do nothing (query is written before the before trigger). see bugs #185, #262
current version takes newvals as is (just adds sqlw) and inserts it (no checking if columns exist in table). so don't be surpised with mysql errors ;)
|
Jochen
Založený: 22.10.2004
Príspevky: 7
Zaslal: 2004-10-24 11:14
Návrat hore
Odpovedať s citátom
|
Oh. When do you think will these changes be available as new stable version?
I tried http://opensource.platon.sk/cvs/cvs.php/phpMyEdit/phpMyEdit.class.php in version 1.147 (age 3 months) and it works now. Thanks.
Jochen
|
|
Odoslať novú tému
Odpovedať na tému
|
|
|
|