RCurtis
Založený: 19.09.2013
Príspevky: 10
Zaslal: 2013-09-19 14:31
Návrat hore
Odpovedať s citátom
|
Please forgive me...this may be very simple for most of you...I'm just learning.
I have 2 tables (user, user_extended)
Both tables have a matching key value (user_id in the user table, user_extended_id in the user_extended table) which allow records to be matched. In other words, there is a one-to-one relationship for every record.
The user_extended table contains the data I want to edit. What I need to do is a basic edit of the entire user_extended table, but display READ-ONLY the key between the tables and perhaps two fields from the user table READ-ONLY (for example purposes we'll say the "First_Name" and "Last_Name" records from user)
As I said...this is *probably very simple but I'm struggling trying to make it work. Any help appreciated!
|
doug
Založený: 10.02.2003
Príspevky: 1013
Bydlisko: Denver, Colorado (USA)
Zaslal: 2013-09-29 12:42
Návrat hore
Odpovedať s citátom
|
'input' => 'R' may be what you're looking for. Usually it is 'input' => '' and the R will make the field Read Only.
|
RCurtis
Založený: 19.09.2013
Príspevky: 10
Zaslal: 2013-10-04 13:01
Návrat hore
Odpovedať s citátom
|
Yes...I understand the "R" input option. My problem is in the mechanics of getting fields from 2 different tables to display so that the "R" can be applied to 1 or more fields. I see so many people asking this question in the forum...basically "How do I do a table join" and there are only 2 or 3 responses that seem to be given...and yet the questions keep coming.
There is obviously a lot of confusion (for whatever reason) surrounding this particular topic. I admit I am no coding genius...but it sure seems that a definitive example would benefit the whole community. Perhaps it is felt that a sufficient example already exists...my response to that then would be "Why then are so many people asking this same question?"
Let me lay the groundwork and hopefully the response can be a reference for others...
Table1
key
First_Name
Last_Name
Data1
Data2
Data3...
Table2
key
DataA
DataB
DataC...
"key" value is the relational key between both fields.
Desired action for PME is to show the key and First_Name, Last_Name as Read-Only, and then all other data fields from Table2 allowing edit.
This should serve as an excellent example and reference for many people. Could somebody *please* post the entire code to perform this? Many Many thanks to anyone that can do this!
|
doug
Založený: 10.02.2003
Príspevky: 1013
Bydlisko: Denver, Colorado (USA)
Zaslal: 2013-10-04 21:26
Návrat hore
Odpovedať s citátom
|
Documentation is here:
http://opensource.platon.sk/projects/doc.php/phpMyEdit/html/configuration.input-restrictions.html
Personally, I never had much success with JOIN and try to avoid having to use it. I have more success using phpMyAdmin to create a VIEW and then using phpMyEdit to display the VIEW, though obviously a VIEW cannot be edited.
|
RCurtis
Založený: 19.09.2013
Príspevky: 10
Zaslal: 2013-10-08 02:55
Návrat hore
Odpovedať s citátom
|
I am very close to my desired solution...but still scratching my head. There seems to be an inescapable "either/or" situation with virtual fields and joins.
user_extended_id is the main table key. The join table is needed to go and get the "real" user name
This almost works:
| Kód: |
$opts['fdd']['user_extended'] = array(
'name' => 'User Name',
'input' => 'VR',
// When 'C' is added to options below
// get "unknown column" 'user_extended'
// When the real field user_extended_id is used in $opts
// no data shows in change form
'options' => 'LFAPDV',
'sql' => '"bogus_something"', // This was in an example...
'escape' => 'false',
'sort' => true,
'values' => Array(
'table' => $join_table,
'column' => 'user_id',
'description' => 'user_name',
'join' => '$main_table.user_extended_id = $join_table.user_id',
)
);
|
Can anybody see what I'm doing wrong? I don't particularly need to display the key...but PME seems to require this in order to work. But once you've defined/used it in your field listing How can you "use it again"?
All I want to do is have a list view and a Change view that will show my "user Name" field which was determined by table join and matching against key fields in 2 different tables.
|
nepto
Založený: 06.01.2003
Príspevky: 320
Bydlisko: Phoenix, Arizona (USA)
Zaslal: 2013-10-08 19:00
Návrat hore
Odpovedať s citátom
|
Try this:
| Kód: |
$opts['fdd']['user_extended_id'] = array(
'name' => 'User Name',
'input' => 'R',
'values' => array(
'table' => 'user',
'column' => 'user_id',
'description' => array(
'columns' => array('Last_Name', 'First_Name', 'user_id'),
'divs' => array(', ', ' (', ')')
)
)
|
|
RCurtis
Založený: 19.09.2013
Príspevky: 10
Zaslal: 2013-10-10 15:32
Návrat hore
Odpovedať s citátom
|
Many thanks for the reply nepto...
I think we may be close, but I get:
| Kód: |
MySQL error 1054
Unknown column 'PMEjoin0.Last_Name' in 'field list' |
Doesn't there need to be a "join" somewhere in there?
|
nepto
Založený: 06.01.2003
Príspevky: 320
Bydlisko: Phoenix, Arizona (USA)
Zaslal: 2013-10-11 01:44
Návrat hore
Odpovedať s citátom
|
| RCurtis Napísal: |
MySQL error 1054
Unknown column 'PMEjoin0.Last_Name' in 'field list'
Doesn't there need to be a "join" somewhere in there? |
No need for join, in this simple case.
Regarding to error: you said you have
Last_Name
column in
user
table, right? It looks like it is not there. Please check.
|
RCurtis
Založený: 19.09.2013
Príspevky: 10
Zaslal: 2013-10-11 03:33
Návrat hore
Odpovedať s citátom
|
OK...I went back and reviewed what I posted as my "example". I got things crossed up!
Let's restate what the facts *really* are...sorry!
Table1 name - e107_user_extended
user_extended_id (key)
First_Name
Last_Name
Data1
Data2
Data3...
Table2 name - e107_user
user_id (key)
username
DataA
DataB
DataC...
"user_id" and "user_extended_id" values are the relational keys between both fields.
Table1 is the PME main table
Table2 is the PME join table
Desired action for PME is to show Table1 with the key and First_Name, Last_Name as Read-Only *and the username field from Table2*, and then all other data fields from Table2 allowing edit.
|
admin
Site Admin
Založený: 06.01.2003
Príspevky: 12
Bydlisko: Bratislava, Slovakia
Zaslal: 2013-10-12 02:10
Návrat hore
Odpovedať s citátom
|
You cannot edit data from join table.
You will have to make a calling script for
e107_user
and then, optionally, fetch some data from the other table.
However there is
definitelly
no way how to edit two tables at once (in phpMyEdit).
|
RCurtis
Založený: 19.09.2013
Príspevky: 10
Zaslal: 2013-10-12 02:20
Návrat hore
Odpovedať s citátom
|
I don't want to edit the data from the join table...just want to display it read-only. Only the main table fields will be edited.
|
doug
Založený: 10.02.2003
Príspevky: 1013
Bydlisko: Denver, Colorado (USA)
Zaslal: 2013-10-12 16:04
Návrat hore
Odpovedať s citátom
|
Make a VIEW using phpMyAdmin. Read the VIEW using phpMyEdit.
|
RCurtis
Založený: 19.09.2013
Príspevky: 10
Zaslal: 2013-10-12 20:35
Návrat hore
Odpovedať s citátom
|
Please correct me if I'm wrong, but I seem to remember that you told somebody else to do this...but that "of course you will not be able to edit..." with PME. ??
|
|
Odoslať novú tému
Odpovedať na tému
|