3

I have a controller and model both named "account" without getting "cannot redeclare class". I'd like to add a prefix to Models or Controllers, or preferably both.

Any ideas?

Ben
  • 60,438
  • 111
  • 314
  • 488

2 Answers2

9

I suggest that you call your model "account_model" and reference it like this:

$this->load->model('account_model', 'account');
$this->account->function();

I know it doesn't solve the problem, however I think that you might find it an adequate solution!

Henry
  • 290
  • 1
  • 2
  • 6
  • 1
    This is a really great answer and a very simple solution. Modifying the underlying framework is not at all necessary, especially when @Henry notes that Codeigniter provides a means to give your model an alias on the fly. – hypervisor666 May 03 '11 at 02:02
0

There should be an issue with this. if it was me, i would be a bit more descriptive with the prefix so you remember what the model or controller was for. I only say this because "account" is a little vague.

Jason Shultz
  • 940
  • 1
  • 19
  • 36