• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Could I use the model in the view? Who can help me?

#11
[eluser]sexy22[/eluser]
Thanks everybody!yes,I was understood.In your’s help,I hava solved the problem.

#12
[eluser]nirbhab[/eluser]
STEP1:

load the MODEL in constructor of your Controller so that it is available every where.
STEP2:

load view in any method.
STEP3:

load model in loaded view.
Step4:

you can let model perform any work for you
a. load multiple view
b. db manipulations etc.
c. anything you want to.

SAMPLE:
Controller:[blog.php]


Code:
class Blog extends Controller {

       function Blog()
       {
            parent::Controller();
    $this->load->model('fubarModel', 'fubar');

       }

    function index()
    {
$this->load->view('name');
    }
}


VIEW:[name.php]
Code:
<b>Name View!
$this->fubar->fubarFunction();
</b>

MODEL:[fubarModel.php]

Code:
class fubarModel extends Model {

    function fubarModel()
    {
        parent::Model();
    }
function fubarFunction()
{
$this->load->view('secondname');
}
}

VIEW2['secondname.php']

Code:
<i>Second name view</i>


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.