CodeIgniter Forums
Ancillary Classes in CI4 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Ancillary Classes in CI4 (/showthread.php?tid=77177)



Ancillary Classes in CI4 - psreejiths - 07-29-2020

i am troubling in  call function in My_helper.php  CI4
i can't  call function in helper page , and cannot connect with Model with    $CI =& get_instance(); 
its is showing error, please help ...
how to call  $CI =& get_instance();  in CI 4


RE: Ancillary Classes in CI4 - InsiteFX - 07-29-2020

There is no CI 4 get_instance like CI 3 it's all OOP now.

Helpers are load by an array anywhere or by the array in the BaseController.


RE: Ancillary Classes in CI4 - psreejiths - 07-30-2020

(07-29-2020, 02:58 AM)InsiteFX Wrote: There is no CI 4 get_instance like CI 3 it's all OOP now.

Helpers are load by an array anywhere or by the array in the BaseController.
How to call the controller function or model function inside a  particular helper function?

function allcustomers($x)
{
$ci =& get_instance();
$customer_datas=$ci->invoice_model->getallcustomers($x);
echo "<select id='customer' name='customer' class='form-control required' required>";
echo '<option value="">Please Select</option>';
foreach($customer_datas as $listcustomer)
{
echo "<option value='$listcustomer[customer_id]'>$listcustomer[customer_name]</option>";
}
echo "</select>";
}