CodeIgniter Forums
Call a controller from a Model - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Call a controller from a Model (/showthread.php?tid=30037)



Call a controller from a Model - El Forum - 04-30-2010

[eluser]Alface[/eluser]
First I need to know, I know MVC.
I realy need to do it.

Code:
<?php
class Site extends Controller {
    function Site(){
        parent::Controller();
    }

    function say(){
             echo 'hello';
        }
}

Code:
<?php
class Something_model extends Model {

    public function __construct(){
        parent::Model();
    }
    
    function dolikecontroller(){
        // something to call 'say' function from controller
    }
}


There is no libary extention for do it?

Thanks


Call a controller from a Model - El Forum - 04-30-2010

[eluser]theshiftexchange[/eluser]
Whatever your trying to do - wouldnt it be easier making a library yourself, and then have both the controller and the model call that library? Thus achieving the same goal but in true MVC format?


Call a controller from a Model - El Forum - 04-30-2010

[eluser]danmontgomery[/eluser]
Code:
function dolikecontroller() {
    $CI =& get_instance();
    $CI->say();
}



Call a controller from a Model - El Forum - 04-30-2010

[eluser]Alface[/eluser]
Didn't worked.
I was tring to make a xajax aplication faster..

I solved it calling the same function with call xajax on controller


Call a controller from a Model - El Forum - 05-01-2010

[eluser]stuffradio[/eluser]
Woah woah woah, why are you trying to do that? Isn't that kind of backwards!?


Call a controller from a Model - El Forum - 05-01-2010

[eluser]Alface[/eluser]
[quote author="stuffradio" date="1272752731"]Woah woah woah, why are you trying to do that? Isn't that kind of backwards!?[/quote]

Because the Database access is done on controller (I'm using ORM)