CodeIgniter Forums
Extending the native Model in Codeigniter 2 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Extending the native Model in Codeigniter 2 (/showthread.php?tid=38039)



Extending the native Model in Codeigniter 2 - El Forum - 01-28-2011

[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


Extending the native Model in Codeigniter 2 - El Forum - 01-28-2011

[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