201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
|
if (!empty($data[$champ_id])
&& $db->firstColumn('SELECT 1 FROM membres WHERE '.$champ_id.' = ? COLLATE NOCASE AND id != ? LIMIT 1;', $data[$champ_id], (int)$id))
{
throw new UserException('La valeur du champ '.$champ_id.' est déjà utilisée par un autre membre, hors ce champ doit être unique à chaque membre.');
}
if (!empty($data['numero']))
{
if (!preg_match('/^\d+$/', $data['numero']))
{
throw new UserException('Le numéro de membre ne doit contenir que des chiffres.');
}
if ($db->test('membres', 'numero = ? AND id != ?', (int)$data['numero'], $id))
{
throw new UserException('Ce numéro est déjà attribué à un autre membre.');
}
}
|
|
>
>
>
>
|
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
|
if (!empty($data[$champ_id])
&& $db->firstColumn('SELECT 1 FROM membres WHERE '.$champ_id.' = ? COLLATE NOCASE AND id != ? LIMIT 1;', $data[$champ_id], (int)$id))
{
throw new UserException('La valeur du champ '.$champ_id.' est déjà utilisée par un autre membre, hors ce champ doit être unique à chaque membre.');
}
if (isset($data['numero']))
{
if (!preg_match('/^\d+$/', $data['numero']))
{
throw new UserException('Le numéro de membre ne doit contenir que des chiffres.');
}
elseif ($data['numero'] == 0)
{
throw new UserException('Le numéro de membre ne peut être vide.');
}
if ($db->test('membres', 'numero = ? AND id != ?', (int)$data['numero'], $id))
{
throw new UserException('Ce numéro est déjà attribué à un autre membre.');
}
}
|