Welcome Guest, Not a member yet? Register   Sign In
Added CI_ Prefix to all core classes?
#1

[eluser]anna16[/eluser]
Hi guys

What do you mean by this --> "Added CI_ Prefix to all core classes"?

Is this mean all classes in the controller, library and model will have
a class name like this --> CI_Classname

Can you clarify and give example to thi please?

Thanks in advanced.
#2

[eluser]daparky[/eluser]
Yep, you have to put a prefix of CI_ e.g. MY_Controller extends CI_Controller or Mymodel extends CI_Model.

Hope this makes sense.
#3

[eluser]Pedro Luz[/eluser]
now all controllers and models must have this structure

for controllers:
Code:
class Foo extends CI_Controller
{
function __construct()
{
parent::__construct();
}
}

for models
Code:
class Bar_model extends CI_Model
{
function __construct()
{
parent::__construct();
}
}
#4

[eluser]Adolfo Reyes[/eluser]
I upgraded an existing application to CI v2, changed all the controllers and models to "extends CI_" and now I get

"Fatal error: Class 'CI_Controller' not found in"

What's wrong?
#5

[eluser]InsiteFX[/eluser]
Did you copy over the new index.php ?

The new index.php points to core not codeigniter.

InsiteFX
#6

[eluser]ludovic[/eluser]
[quote author="Pedro Luz" date="1296493653"]now all controllers and models must have this structure
Code:
class Foo extends CI_Controller
{
function __construct()
{
parent::__construct();
}
}

For me function __construct() don't work, but only construct() or like this

Code:
class Foo extends CI_Controller
{
function Foo()
{
parent::__construct();
}
}
#7

[eluser]Adolfo Reyes[/eluser]
[quote author="InsiteFX" date="1296997692"]Did you copy over the new index.php ?

The new index.php points to core not codeigniter.

InsiteFX[/quote]


That was it! Thank you InsiteFX.

What was the reasoning for implementing the prefix on controllers and models? I prefer the previous convention, without the prefix. The code looks cleaner.
#8

[eluser]InsiteFX[/eluser]
Just away for Codeigniter to stay consitant with other library
namings.

InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB