I've made a web site using Codeigniter and I'm facing the issue related with speed.
All other functionality is much faster but I don't know why it takes too much time to load.
Well Only one query will perform for that operation but waiting time is too much high.
This issue is occurred first time when website is load.
// Controller
function hardwareFolder($uId){
$Folder = $this->System_model->get_folder_category_id($uId);
$menu = [
[
'id' => 'all',
'pId' => '1',
'name' => _('All'),
'icon' => base_url('images/directory_icon.gif'),
'isParent' => true,
'checked' => true,
'nocheck' => true,
'open' => true,
'dirlevel' => 'main',
'dirType' => 'all',
],
[
'id' => $Folder[0]['c_type_id'],
'pId' => $Folder[0]['c_type_pid'],
'name' => 'Unfiled',
'icon' => base_url('images/unfield.png'),
'isParent' => true,
'checked' => true,
'nocheck' => true,
'open' => true,
'dirlevel' => 'main',
'dirType' => 'unfiled',
],
[
'id' => $Folder[1]['c_type_id'],
'pId' => $Folder[1]['c_type_pid'],
'name' => _('Shared'),
'icon' => base_url('images/sharedir.png'),
'isParent' => true,
'checked' => true,
'nocheck' => true,
'open' => true,
'dirlevel' => 'main',
'dirType' => 'shared',
],
];
return $this->output
->set_content_type('application/json')
->set_output(json_encode($menu));
}
// Model
function get_folder_category_id($uid){
$q_s_type = "SELECT c_type_id,c_type_pid,c_type_name " .
"FROM `codeigniter_system_category_type` " .
" WHERE `c_type_pid` = 0 " .
"AND `c_type_name` = 'Others' " .
"AND `c_module` = 'System' " .
"AND `c_created_userID` = ".$uid .
" UNION SELECT c_type_id,c_type_pid,c_type_name ".
" FROM `codeigniter_system_category_type` " .
"WHERE `c_type_pid` = 0 " .
"AND `c_type_name` = 'Shared' " .
"AND `c_module` = 'System' " .
"AND `c_created_userID` = ".$uid;
return $this->db->query($q_s_type)->result_array();
}
Script call with Ajax.