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  »  Please help me to join two tables

phpMyEdit General     Please help me to join two tables
Odoslať novú tému   Odpovedať na tému    
 
DavidLi     Založený: 24.11.2004   Príspevky: 4  
Príspevok Zaslal: 2005-08-04 18:31
Návrat hore  Odpovedať s citátom     

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     Založený: 07.03.2004   Príspevky: 17  
Príspevok Zaslal: 2005-08-04 20:24
Návrat hore  Odpovedať s citátom     

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

Kód:

$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

Kód:

$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     Založený: 24.11.2004   Príspevky: 4  
Príspevok Zaslal: 2005-08-05 13:33
Návrat hore  Odpovedať s citátom     

I need to values in column reg from tables phh find out all values from columns tables p where phh.reg = p.reg

 
phredbroughton     Založený: 07.03.2004   Príspevky: 17  
Príspevok Zaslal: 2005-08-09 17:27
Návrat hore  Odpovedať s citátom     

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.

Kód:

// 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//
      )
);


 
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