Bonjour

Malgré une prise en main qui semble facile, je n'arrive pas à me dépatouiller avec ce cas. Je souhaite gérer 3 tables avec phpMyEdit, voici ma structure de DB:


Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
Table groups:
+-----------+
| groupname |
+-----------+
| gr1 |
| gr2 |
+-----------+
 
Table usergroup:
+---------------+-----------+
| username | groupname |
+---------------+-----------+
| user1 | gr1 |
| user1 | gr2 |
| user2 | gr1 |
| user3 | gr2 |
+---------------------------+
 
Table users:
+---------------+---------------+
| username | passwd |
+---------------+---------------+
| user1 | xxxxxxxx |
| user2 | xxxxxxxx |
| user3 | xxxxxxxx |
+-------------------------------+
En fait, je ne souhaite pas avoir une vue de la table usergroup mais gérer cela via la table users, avec une vue comme ceci:

username | passwd | groups
(user1) | xxxxxx | gr1,gr2

Ma difficulter est de faire la jointure avec phpMyEdit et de pouvoir attribuer les groupes aux users directement dans la table users et que ça mette à jour dans la table usergroup. Il semble bien que cela soit possible mais je n'y arrive pas.

Est-ce que l'un d'entre vous voit comment faire.
Merci d'avance des propositions
skeut

P.S. ci-dessous, mon début de script PHP pour la table users
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
		"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
	<title>REFDATA: usermanagement-tool</title>
	<link rel="stylesheet" type="text/css" href="css/admin.css" />
</head>
<body>
 
<?php
 
//for the db connection
require_once '../../config/config.php';
 
// extract file name
$file = $_SERVER["SCRIPT_NAME"];
$break = Explode('/', $file);
$pfile = $break[count($break) - 1];
 
// display navigation
foreach ($tab_menu as $key=>$value) {
	include '../../../include/navi_tabs.inc';
}
 
$opts['tb'] = 'users';
// Name of field which is the unique key
$opts['key'] = 'username';
 
// type of unique field (int/real/string/date etc.)
$opts['key_type'] = 'string';
 
// sort on field ?
$opts['sort_field'] = array('username');
 
//number of records on the page ?
// -1 for display all records
$opts['inc'] = 20;
 
// Wich options for the user ?
// A - add,  C - change, P - copy, V - view, D - delete,
// F - filter/search, I - initial sort suppressed
$opts['options'] = 'ACVDL';
 
//number of rows if multiple choice
$opts['multiple'] = '4';
 
// navigation style : B - buttons (default), T - text links, G - graphic links
// Position des boutons : U - up, D - down (default)
$opts['navigation'] = 'GBD'; 
 
// Display special page elements
$opts['display'] = array(
	'form'  => true,
	'query' => false,
	'sort'  => false,
	'time'  => false,
	'tabs'  => true
);
 
/* Get the user's default language and use it if possible or you can
   specify particular one you want to use. Refer to official documentation
   for list of available languages. 
  Langage par défaut , pas besoin de toucher normalement
*/
$opts['language'] = $HTTP_SERVER_VARS['HTTP_ACCEPT_LANGUAGE'];
 
/* Table-level filter capability. If set, it is included in the WHERE clause
   of any generated SELECT statement in SQL query. This gives you ability to
   work only with subset of data from table.
   Exemple de filtres qu'on peux appliquer pour limiter la selection

$opts['filters'] = "column1 like '%11%' AND column2<17";
$opts['filters'] = "section_id = 9";
$opts['filters'] = "PMEtable0.sessions_count > 200";
*/
 
/* THE MAIN OPTIONS FOR EACH FIELD
   
Fields will be displayed left to right on the screen in the order in which they
appear in generated list. Here are some most used field options documented.

['name'] is the title used for column headings, etc.;
['maxlen'] maximum length to display add/edit/search input boxes
['trimlen'] maximum length of string content to display in row listing
['width'] is an optional display width specification for the column
          e.g.  ['width'] = '100px';
['mask'] a string that is used by sprintf() to format field output
['sort'] true or false; means the users may sort the display on this column
['strip_tags'] true or false; whether to strip tags from content
['nowrap'] true or false; whether this field should get a NOWRAP
['required'] true or false; if generate javascript to prevent null entries
['select'] T - text, N - numeric, D - drop-down, M - multiple selection
['options'] optional parameter to control whether a field is displayed
  L - list, F - filter, A - add, C - change, P - copy, D - delete, V - view
            Another flags are:
            R - indicates that a field is read only
            W - indicates that a field is a password field
            H - indicates that a field is to be hidden and marked as hidden
['URL'] is used to make a field 'clickable' in the display
        e.g.: 'mailto:$value', 'http://$value' or '$page?stuff';
['URLtarget']  HTML target link specification (for example: _blank)
['textarea']['rows'] and/or ['textarea']['cols']
  specifies a textarea is to be used to give multi-line input
  e.g. ['textarea']['rows'] = 5; ['textarea']['cols'] = 10
['values'] restricts user input to the specified constants,
           e.g. ['values'] = array('A','B','C') or ['values'] = range(1,99)
['values']['table'] and ['values']['column'] restricts user input
  to the values found in the specified column of another table
['values']['description'] = 'desc_column'
  The optional ['values']['description'] field allows the value(s) displayed
  to the user to be different to those in the ['values']['column'] field.
  This is useful for giving more meaning to column values. Multiple
  descriptions fields are also possible. Check documentation for this.
*/
 
$opts['fdd']['username'] = array(
  'name'     => 'Username',
  'select'   => 'T',
  'maxlen'   => 20,
  'required' => true,
  'sort'     => true
);
$opts['fdd']['passwd'] = array(
  'default'    => '',
  'input'      => 'W',
  'name'     => 'Password',
  'select'   => 'T',
  'maxlen'   => 60,
  'required' => true,
  'sort'     => false,
  'help' => 'the password is encrypted',
  'sqlw' => 'ENCRYPT(TRIM("$val_as"))'
);
 
$main_table = 'users';
$join_table = 'usergroup';
 
$opts['fdd']['virt'] = array(
  'name'     => 'Group(s)',
  'help|AC'   => 'Select one to n groups',
  'input'   => 'V', // virtual
  'options'  => 'ACVDL',
  'select'   => 'M',
  'size|AC' => 50,
  'sql'      => 'PMEjoin2.groupname',
  'sqlw'       => 'IF($val_qas = "", NULL, $val_qas)', 
  'values'   => Array('table' => 'usergroup', 'column' => 'groupname', 'description' => 'groupname','join' => '$main_table.username = $join_table.username'),
  'help|AC'   => 'Select one to n groups',
  'sort'     => true
);
 
// call the class
require_once 'lib/phpMyEditClass.php';
new edit($opts);
 
?>
 
</body>
</html>