Welcome Guest, Not a member yet? Register   Sign In
OO usage in code igniter structure, Model, Controller
#1

[eluser]farinspace[/eluser]
I am trying to get into the work flow of codeigniter and would like some practical examples. My one main question is about proper OO usage within models/controllers (please forgive me if im just being dense and the answer is just staring me in the face) ...

Basic example (outside of codeigniter)
Code:
$link = new Link($db,55);

$link2 = new Link($db);
$link2->title = 'link title 1';

$link3 = new Link($db);
$link3->title = 'link title 2';

$link->append($link2);
$link->insert($link3);

echo $link->title;
echo $link->description;

$tree = $link->get();
var_dump($tree);

All the codeigniter model examples I've seen, seem to be more on the concept of a "manager" pattern, instead of managing single objects and having them interact with one another ...

Code:
// inside a controller function

$this->load->model('link');
$this->link->appendLink('link title 1',55);
$this->link->appendLink('link title 2',55);

$title = $this->link->getTitle(55);
$desc = $this->link->getDescription(55);
$tree = $this->link->get(55); // gets tree starting at this links ID/level

Lets say I wanted my model to return an object, how does the model go about creating an instance of another model/class (possibly passing an initialization parameter, and using existing db connection) and returning that object ... all with in the codeigniter framework?


Messages In This Thread
OO usage in code igniter structure, Model, Controller - by El Forum - 11-14-2008, 04:07 PM
OO usage in code igniter structure, Model, Controller - by El Forum - 11-15-2008, 02:14 PM
OO usage in code igniter structure, Model, Controller - by El Forum - 11-15-2008, 04:33 PM
OO usage in code igniter structure, Model, Controller - by El Forum - 11-15-2008, 04:41 PM
OO usage in code igniter structure, Model, Controller - by El Forum - 11-15-2008, 05:28 PM
OO usage in code igniter structure, Model, Controller - by El Forum - 11-15-2008, 06:14 PM
OO usage in code igniter structure, Model, Controller - by El Forum - 11-15-2008, 07:25 PM



Theme © iAndrew 2016 - Forum software by © MyBB