php - How to load one helper function in all the controller functions without calling it everytime in all the functions -


i want add these helper function in controller functions

// helper file custom_helper.php  // $autoload['helper'] = array('url','form', 'custom_helper');  function notifications() {     $ci = get_instance();     $ci->load->model('custom_model');     $select = "id, name";     $tablename = "users";     $wherecondition = "created_at = curdate()";     $result = $ci->custom_model                      ->fetchwithselect($select,$tablename,$wherecondition);            return $result; } 

create helper file in application/helper folder: xyz_helper.php

<?php     defined('basepath') or exit('no direct script access allowed');      function notifications()      {         $ci = get_instance();         $ci->load->model('custom_model');         $select = "id, name";         $tablename = "users";         $wherecondition = "created_at = curdate()";         $result = $ci->custom_model                      ->fetchwithselect($select,$tablename,$wherecondition);                return $result;     } 

then open application/config/autoload.php file : add this

$autoload['helper'] = array('url', 'file','form','xyz'); 

also don't need put "custom_helper" in $autoload['helper'], put "custom" , file in application/helper/custom_helper.php


Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -