04-10-2008, 08:21 PM
(Modification du message : 04-10-2008, 08:57 PM par Sephi-Chan.)
Plop !
Ma question est simple mais je ne sais pas si la réponse l'est aussi.
J'aimerais savoir s'il est possible de faire ceci :
Ma question est simple mais je ne sais pas si la réponse l'est aussi.
J'aimerais savoir s'il est possible de faire ceci :
Code PHP :
<?php
$loginSelect = "SELECT COUNT(id) AS nbLogin FROM users WHERE login = %s";
$loginQuery = sprintf($loginSelect, $this->input->post('login'));
$loginResult = $this->db->query($loginQuery);
$nbLogin = $loginResult->result_array();
if($nbLogin['nbLogin'] > 0){
$this->validation->login_error = $this->lang->line('This login is already used.');
$this->layout->view('profile/inscriptionForm');
return FALSE;
}
$emailSelect = "SELECT COUNT(id) AS nbEmail FROM users WHERE email = %s";
$emailQuery = sprintf($emailSelect, $this->input->post('email'));
$emailResult = $this->db->query($emailQuery);
$nbEmail = $emailResult->result_array();
if($nbEmail['nbEmail'] > 0){
$this->validation->email_error = $this->lang->line('This email is already used.');
$this->layout->view('profile/inscriptionForm');
return FALSE;
}
$nameSelect = "SELECT COUNT(id) AS nbName FROM users WHERE lastname = %s AND firstname = %s";
$nameQuery = sprintf($nameQuery, $this->input->post('lastname'), $this->input->post('firstname'));
$nameResult = $this->db->query($nameQuery);
$nbName = $nameResult->result_array();
if($nbName['nbName'] > 0){
$this->validation->firstname_error = $this->lang->line('These firstname and lastname are already used.');
$this->layout->view('profile/inscriptionForm');
return FALSE;
}
Mais avec une seule requête ?
Merci !
@tchaOo°