DavidLi
Joined: 24 Nov 2004
Posts: 4
Posted: 2005-08-04 18:31
Back to top
Reply with quote
|
I am a newbee with PME and I am stil confused with joinnig tables after perusal forums. So that am found courage ask you for help. How to join this table please.
primary table:
CREATE TABLE phh (
reg char(7) NOT NULL default '',
dc tinyint(4) default NULL,
st tinyint(4) default NULL,
r int(2) default NULL,
PRIMARY KEY (reg)
) TYPE=MyISAM;
with joined table:
CREATE TABLE p (
reg varchar(7) NOT NULL default '',
name text,
father_name text,
mother_name text,
PRIMARY KEY (reg)
) TYPE=MyISAM;
phh.reg = p.reg
Behind of what-wheels help in advance thank you
DavidLi
|
phredbroughton
Joined: 07 Mar 2004
Posts: 17
Posted: 2005-08-04 20:24
Back to top
Reply with quote
|
I'm a bit confused by the table structure and exactly how you want to join them. Not sure if this will help, but I will try to answer by example. In your config file for phh you would need something like
| Code: |
$opts['fdd']['reg'] = array(
'name' => 'Display Title for this Field',
'select' => 'T',
'maxlen' => 7,
'default' => 'somedefault value',
'sort' => true,
'values' => array(
'table' => 'ph',
'column' => 'reg',
'description'=> 'name',
'orderby'=>'name'
)
);
|
This would display any linked "name" field in the list screen and give you a dropdown select list in the change screen. You can play around with the field Option values and use Option Variability to get different results for display. (Check documentation for these)
Or to use more than one field as the displayed value
| Code: |
$opts['fdd']['reg'] = array(
'name' => 'Display Title for this Field',
'select' => 'T',
'maxlen' => 7,
'default' => 'somedefault value',
'sort' => true,
'values' => array(
'table' => 'ph',
'column' => 'reg',
'description'=> array(
'columns' => array(
'0' => 'name',
'1' => 'father_name',
'2' => 'mother_name'
),
'divs' => array(
'0' => ' - ',
'1' => ' - '
),
),
'orderby'=>'name'
)
);
|
Check the online docs under field options
[url]
http://opensource.platon.sk/projects/doc.php/phpMyEdit/html/configuration.input-restrictions.html
[/url]
Hopefully this will be somewhat helpful. Good luck!!
|
DavidLi
Joined: 24 Nov 2004
Posts: 4
Posted: 2005-08-05 13:33
Back to top
Reply with quote
|
I need to values in column reg from tables phh find out all values from columns tables p where phh.reg = p.reg
|
phredbroughton
Joined: 07 Mar 2004
Posts: 17
Posted: 2005-08-09 17:27
Back to top
Reply with quote
|
Sorry, I called the second table "ph" instead of "p", but this is how you would display any fields from the "p" table.
In your phh table config you would have something like this. This will use the value in phh.reg to match to p.reg and display "name - father-name - mother-name" as the column data. There are more options than I can detail here that you can use to customize this, but this should get you started.
| Code: |
// This is the field setup for phh.reg
$opts['fdd']['reg'] = array(
'name' => 'Display Title for this Field',
'select' => 'T',
'maxlen' => 7,
'default' => 'somedefault value',
'sort' => true,
'values' => array(
'table' => 'p', // This tells PME to lookup in the "p" table //
'column' => 'reg', // This tells PME to match on the p.reg field value and if this is setup as a select list (ie. not readonly option) then this is the value returned into phh.reg on selection//
'description'=> array( // this array describes the fields and dividers placed between them that will be displayed for this field in list and view etc. If ['options'] => 'R' is set, then it will only display if there is a match//
'columns' => array(
'0' => 'name',
'1' => 'father_name',
'2' => 'mother_name'
),
'divs' => array(
'0' => ' - ',
'1' => ' - '
),
),
'orderby'=>'name' // this orders the list if the user is allowed to change the field and a drop down select list is displayed//
)
);
|
|
|
Post new topic
Reply to topic
|
|