1

I need to use controller System inside controller Historic because i have some problems with cron.

When i try to load like this:

$this->load->library('../controllers/system');

i get error:

Unable to locate the specified class: System.php

System.php class does not exists, there is System class in System.php file what i want to call from Historic.php controller.

How can i solve this?

DocNet
  • 460
  • 3
  • 9
  • 24
  • Why don't you just make an object of that System class. – Mr. Engineer Feb 02 '16 at 11:55
  • @Mr.Engineer You think like this: $system = $this->load->library('../controllers/system'); ? This don't works. Same error – DocNet Feb 02 '16 at 12:00
  • Ya it doesn't work. Controller cant call as library – Abdulla Nilam Feb 02 '16 at 12:00
  • Like this : `$s = new System();` or `use System` at top of the file. – Mr. Engineer Feb 02 '16 at 12:03
  • @DocNet just try this `$path = APPPATH.'/controllers/system'; $this->load->library($path);` – Abdulla Nilam Feb 02 '16 at 12:03
  • @Abdulla Now i get same error, but instead System.php now display System: Unable to load the requested class: System – DocNet Feb 02 '16 at 12:08
  • @Mr.Engineer I already tried that, but that is inpossible. – DocNet Feb 02 '16 at 12:08
  • @DocNet I just tld some try. Controller cant load as library – Abdulla Nilam Feb 02 '16 at 12:09
  • @Abdulla i check some answers and i see this: http://stackoverflow.com/questions/6091100/codeigniter-load-controller-within-controller check Zulqurnain abbas answer where peoples say that is possible. – DocNet Feb 02 '16 at 12:12
  • Change this `$path = APPPATH.'/controllers/system';` to this `$path = APPPATH.'controllers/system';` – Abdulla Nilam Feb 02 '16 at 12:15
  • @Abdulla Nope, same again. Maybe last ci don't support load controller as libray? :/ What is alternative? – DocNet Feb 02 '16 at 12:18
  • what is in that ?? and what kind of purpose of your usage with that?? – Abdulla Nilam Feb 02 '16 at 12:19
  • In System is function that list all email's from table and send mail to all. Now i want to run that with cron daily, but when i try index.php system runsystem it won't works. But index.php historic works great, so i want to call System function runsystem inside Historic index because cron can run that controller. System controller has some redirects in index() function so that maybe is reason why cron don't run it well, i need to have that redirects. – DocNet Feb 02 '16 at 12:24
  • If your trying to load controller in to another controller use HMVC –  Feb 02 '16 at 20:01

0 Answers0