Appelez simplement where()
dans l'instruction if, avant d'appeler get()
.
$this->db->select('name');
if(isset($name))
{
//add where clause here, to select specific name
$this->db->where('name', $name);
}
$query = $this->db->get('user');
$result_array = $query->result_array();
Documents :
https://www.codeigniter.com/user-guide/database/active_record .html