Welcome Guest, Not a member yet? Register   Sign In
DMZ 1.7.1 (DataMapper OverZealous Edition)

[eluser]Basketcasesoftware[/eluser]
What's the way you are doing it WITH the ORM?

[eluser]ramm[/eluser]
That's the way WITH ORM. I was wondering if there's a better way to do it.

This is just a test, i'm not actually echoing the results in the controller...

[eluser]Basketcasesoftware[/eluser]
Ok. The context implied the code that followed was without ORM. Can you show how you would do it without it then?

In fact, what exactly are you trying to do with the code? And DataMapper is up to version 1.8 now. If you are still using DMZ 1.7.1 (which is implied by you posting in this thread), there might be features available that might make things easier anyways.

[eluser]ramm[/eluser]
Oh, i'm sorry i didn't know it was only for 1.7.1, thought it was growing together...

Anyway, this is the way i do it without ORM, using only CI libraries:

Code:
function test()
    {
        $this->load->model(array('chains_model', 'restaurants_model'));
        $chains = $this->chains_model->get_chains();
        foreach($chains as $c)
        {
            echo "<h3>".$c->name.</h3>;
            $restaurants = $this->restaurants_model->get_restaurants(array('chain' => $c->id));
            foreach($restaurants as $r)
            {
                echo $r->name."<br />";
            }
        }
    }

I need something like this:

Chain: McDonalds
-Mc Donalds Rest I35 North
-Mc Donalds Austin HWY
-Mc Donalds O'Connor Road

Chain: Subway
-Subway Forum
-Subway Nacogdoches
-Subway Northstar Mall

Chain: Red Lobster
-Red Lobster I35 North

And so on...

[eluser]Basketcasesoftware[/eluser]
No, not only. But with the thread title it helps to make sure. There have been cases where people have gotten confused.

And how is the weather right now in San Antonio? Smile

It kind of sucks both of your code posting are on different pages. Makes it kind of tough to compare the two.

[eluser]Basketcasesoftware[/eluser]
Won't this work? You haven't given the structure of your tables so I'm having to guess on the code.
Code:
function test()
    {
        $c = new Chain();
        $c->get();
        
        foreach($c as $chain)
        {
            echo "<h3>".$chain->nme."</h3>";
            foreach($chain->rest as $rest)
            {
                echo $rest->name."<br />";
            }
        }
    }

[eluser]WanWizard[/eluser]
I understand the issue, as it runs 1 query to get the chains, and then 1 query for every chain found to get the restaurants of that chain.

There are now two discussions going on about the same subject. May I suggest we continue there to keep the discussion in one place? I also gave a suggestion for solution there...

[eluser]Basketcasesoftware[/eluser]
Where's the other discussion? the DataMapper 1.8 thread? I was just responding to the posts.

[eluser]Basketcasesoftware[/eluser]
I found it.

[eluser]gowrav vishwakarma[/eluser]
simple question but I am exhausted in finding answer if some one can get me started

I have two tables

--------- users --------------||
|-----------------------------||
|id | field1 | field2 | field3||
|-----------------------------||


|---------------xshouts_members ------
|-------------------------------------|
|id | UID | fieldA | field B | field C|
|-------------------------------------|


Relation is one to one each xshouts_members=>UID represents users=>id
I want

$m = new Member();
$m->get();
echo $m->juser->get()->field2;

yes i want to use juser for users table from xshouts_members point of view (renamed sort of)

and yes may be some day i will need $u->member (from users to member)

thanks for your effort ..




Theme © iAndrew 2016 - Forum software by © MyBB