CodeIgniter Forums
extends MY_Model call twice the __contruct - 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: extends MY_Model call twice the __contruct (/showthread.php?tid=58973)



extends MY_Model call twice the __contruct - El Forum - 08-09-2013

[eluser]Unknown[/eluser]
I have a problem when i try to extends my_model it's call twice the first time is called without parameters, here is the code

MY_Model
Code:
class MY_Model extends CI_Model{
  
public $multiple_array=array();
public $multiple_key=false;

function __construct($tabla='',$id='') {
        parent::__construct();
       $this->load->database();//carga las librerias para manejar db
        $this->tabla=$tabla;
$this->id=$id;
echo "example";  
}
    }

and Prueba_mod
Code:
class Prueba_mod extends MY_Model{
function __construct(){
  parent::__construct("carrera");
  //echo "asdas";
}
}
The echo in the file MY_Model.php will echo twice "example" and if i extends CI_Model it will echo once example.
i would like to understand this behaviour and control it to extends MY_Model and just call once the constructor