Meaning of error in Codeigniter : "Fatal error: Cannot redeclare class My_connection model" Meaning of error in Codeigniter : "Fatal error: Cannot redeclare class My_connection model" codeigniter codeigniter

Meaning of error in Codeigniter : "Fatal error: Cannot redeclare class My_connection model"


The error message is clear: you can't to declare a new class with a name already used in your app.

I used to put a prefix to my models (eg: My_connection_model) to avoid these errors.


I had the above problem. Now, I have solved it. The solution is stupid. But, it work. Actually, the reason to create to such error:

  • when It conflict with its own core classes
  • When, your controller class and model class has same name. While, this is not absolute reason. Because, I run many programs like that. At that time, It show no error. with changing of some configuration, when you try to load. It give error. I solved my error by assigning different names to controller class and model class.

To avoid the problem.

  • use different prefix for controller and model class.Like Myc_ for controller or Mym_ for model.

Note: This is not complete answer. I think, this explanation is not enough to clear the meaning of error. If someone has different solution or meaning to this error. Please, share your solution.