Welcome Guest, Not a member yet? Register   Sign In
MVC Hierarchy question.
#9

[eluser]smalter[/eluser]
Hi all,

I think that i understand somes important thing which missed in my CI logic.

- URI Class
- Redirect function

In my logic, one page = one controller...
I definitely understood that it was not good method.

Then, now i have one "main" function, and, based on URI, which load all the view.

Code:
function load() {
    $uri = $this->uri->segment(3,'home');
    $data = array(
    'last_registred' => $this->members->last_registred(),
    'connected' => $this->members->connected(),
    'registred' => $this->members->registred());
    
    $this->load->view('a2n/'.$uri,$data);
    }

Good?

Now, i can load views dynamically with my $data availaible on her.

But everything is not ok.

In my view "events", i can use $data['last_registred'], $data['connected'], etc,... Nice. But i also want to make a query to get all events from my "events" table.

What's the best way for that?

Create new functions? And in theses functions, re-create my $data array?

Thank's for your help!

Santiago

----------------------------------- En français / In french

Bonjour à tous,

j'ai compris certaines choses importantes qui m'avaient completement échapées.

- La classe URI
- La fonction "redirect" que je peux utiliser dans mes controleurs.

En fait, dans ma logique, pour chaque page, je devais créer un controleur, ce qui n'est pas très simple à gérer... Wink Mais j'ai maintenant bien compris que ce n'était pas la bonne méthode.

Donc, maintenant j'ai un controleur principal, avec une fonction qui va charger la bonne vue en fonction du paramètre que je passe dans l'URI.

Code:
function load() {
    $uri = $this->uri->segment(3,'home');
    $data = array(
    'last_registred' => $this->members->last_registred(),
    'connected' => $this->members->connected(),
    'registred' => $this->members->registred());
    
    $this->load->view('a2n/'.$uri,$data);
    }

Jusque là c'est correct?

Je peux donc accèder à mes variables $data['connected'], $data['registred'], etc,... Dans toutes mes vues qui sont loadé par cette fonction. Parfait.

Mais pour ma vue "agenda" par exemple, je dois aussi faire une requète SQL pour récupérer les éléments de ma table "agenda".

Qu'elle est la meilleures manière de procéder?

Je suis obligé de faire une fonction différente?

J'aimerais pouvoir faire des requètes supplémentaire, pour appeller ma table agenda par exemple, mais sans devoir recréer dans chaque fonction mon array $data principal qui contient $connected, $last_registred, etc,...

Merci d'avance!

Santiago


Messages In This Thread
MVC Hierarchy question. - by El Forum - 12-25-2007, 05:52 PM
MVC Hierarchy question. - by El Forum - 12-25-2007, 10:38 PM
MVC Hierarchy question. - by El Forum - 12-26-2007, 02:13 AM
MVC Hierarchy question. - by El Forum - 12-26-2007, 04:12 AM
MVC Hierarchy question. - by El Forum - 12-26-2007, 04:25 AM
MVC Hierarchy question. - by El Forum - 12-26-2007, 05:26 AM
MVC Hierarchy question. - by El Forum - 12-26-2007, 09:03 PM
MVC Hierarchy question. - by El Forum - 12-26-2007, 11:59 PM
MVC Hierarchy question. - by El Forum - 12-30-2007, 05:30 PM



Theme © iAndrew 2016 - Forum software by © MyBB