Welcome Guest, Not a member yet? Register   Sign In
Extending the native Model in Codeigniter 2
#1

[eluser]Unknown[/eluser]
EDIT: Fixed - should have been in /application/core

I successfully extended the Form_validation library by creating a MY_Form_validation.php in /application/libraries/ - but I can't get the same thing to work with a model.

Error message:
Quote:PHP Fatal error: Class 'MY_Model' not found in /Users/wt ...../application/models/gifts_model.php on line 2

Where /application/models/gifts_model.php has:

Code:
<?php
class Gifts_model extends MY_Model {

    var $table = 'gifts';

    function Gifts_model() {
        // call the model constructor
        parent::__construct();
    }

and /application/libraries/MY_Model.php (which I've also tried putting in the /models/ directory) begins:


Code:
<?php

class MY_Model extends CI_Model {

    function MY_Model()
    {
        parent::__construct();
    }

I assume I've missed something stupid - any ideas?

Thanks,
William
#2

[eluser]danmontgomery[/eluser]
In 2.0, when extending core classes they must go in application/core, not application/libraries

edit: Whoops, just saw you figured this out




Theme © iAndrew 2016 - Forum software by © MyBB