Open nickedes opened 10 years ago
@zishanAhmad see dis
if($this->subject_m->check($array1)){ if($this->subject_m->insert($array)) { $this->data['confirmation'] = 1; } else { $this->data['confirmation'] = 2; } } else { $this->data['confirmation'] = 4; }
and
$array1 = array('username' => $this->input->post('username'));
waah kya naam hai !
why subject_m ?
actually der was a function already der..n it was working der :P
teacher related stuff will be using teacher_m model..
okay..
and check function is
public function check($data) { $query = 'SELECT * FROM teacher where username = ' . $data['username'] ; $q = $this->db->query($query); if($q->num_rows()>0) { return FALSE; } return TRUE; }
if($this->teacher_m->check($data)) {
$array = array('teacher_name' => $this->input->post('teacher_name'), 'username' => $this->input->post('username'), 'password' => $this->teacher_m->hash($this->input->post('password')));
$id = $this->teacher_m->save($array);
unset($array);
$array = array('subject_code' => $this->input->post('subject_code'), 'subject_name' => $this->input->post('subject_name'), 'semester' => $this->input->post('semester'), 'teacher_id' => $id);
if($this->subject_m->insert($array)) {
$this->data['confirmation'] = 1;
} else {
$this->data['confirmation'] = 2;
}
} else {
$this->data['confirmation'] = 4;
}
use this
okk :+1:
just cloning d forked repo again :P
check function main query main there is a problem
query is incorrect oho!
$query = 'SELECT * FROM teacher where username = ' . $data['username'] ; this will give you: SELECT * FROM teacher where username = somename
however, the name should be in quotes.. so instead, use $query = 'SELECT * FROM teacher where username = ' . "'" . $data['username'] . "'" ;
the modified query will give you SELECT * FROM teacher WHERE username = 'somename'
oh..thnx
anytime :)
but wen we write queries in mysql we dont use quotes or anything this is specifically becoz of php ?
no ! we do use quotes when dealing with strings(varchar) but dont use quotes when dealing with numbers
sunoo! here...$data should be an array na? wid username value if($this->teacher_m->check($data)) {
i did this
$array1 = array('username' => $this->input->post('username'));
if($this->teacher_m->check_username($array1)) {.....}
Working now :-)
@zishanAhmad now for edit_teacher() i will use update query for editing details ?
$query = "UPDATE teacher
SET username
= 'UPDATED ITEM';
i will do like dis only na?
why dont you use the save method that is already defined in my_model ? the save method works this way:
oki :shaved_ice:
how to call save method?
$this->teacher_m->save($data, $id)
ok
@zishanAhmad see dis
$array = array('teacher_name' => $this->input->post('teacher_name'), 'username' => $this->input->post('username'), 'password' => $this->teacher_m->hash($this->input->post('password')));
if($this->teacher_m->check_username($array)) {
$id1 = $this->teacher_m->save($array,$this->data['teacher_id']);
unset($array);
$array = array('subject_code' => $this->input->post('subject_code'), 'subject_name' => $this->input->post('subject_name'), 'semester' => $this->input->post('semester'), 'teacher_id' => $id);
if($this->teacher_m->save($array,$this->data['teacher_id'])) {
$this->data['confirmation'] = 1;
} else {
$this->data['confirmation'] = 2;
}
} else {
$this->data['confirmation'] = 4;
}
sorry by mistake close hua..
looks good to me !
ok
regarding teacher username check