[-][+] demo@doophp
Doophp Database ORM demo. Class used - DooSqlMagic
...

Food with Ingredients

Result: SQL executed.

SELECT *, food.id AS _food__id, ingredient.id AS _ingredient__id, food.name AS _food__name, ingredient.name AS _ingredient__name, food_has_ingredient.ingredient_id, food_has_ingredient.food_id
                        ,food_has_ingredient.ingredient_id AS _ingredient__food_id
                        ,food_has_ingredient.food_id AS _food__ingredient_id
                        FROM food
                        LEFT OUTER JOIN food_has_ingredient
                        ON food.id = food_has_ingredient.food_id
                        LEFT OUTER JOIN ingredient
                        ON ingredient.id = food_has_ingredient.ingredient_id
                        WHERE ingredient.id IS NOT NULL AND food.id IS NOT NULL
                        ORDER BY   food_has_ingredient.ingredient_id,food_has_ingredient.food_id ASC
                         

Array
(
    [0] => Food Object
        (
            [id] => 5
            [name] => Asam Laksa
            [description] => Sour & spicy noodles
            [location] => Malaysia
            [food_type_id] => 1
            [_table] => food
            [_primarykey] => id
            [_fields] => Array
                (
                    [0] => id
                    [1] => name
                    [2] => description
                    [3] => location
                    [4] => food_type_id
                )

            [Ingredient] => Array
                (
                    [0] => Ingredient Object
                        (
                            [id] => 1
                            [name] => water
                            [_table] => ingredient
                            [_primarykey] => id
                            [_fields] => Array
                                (
                                    [0] => id
                                    [1] => name
                                )

                        )

                    [1] => Ingredient Object
                        (
                            [id] => 3
                            [name] => shredded fish
                            [_table] => ingredient
                            [_primarykey] => id
                            [_fields] => Array
                                (
                                    [0] => id
                                    [1] => name
                                )

                        )

                    [2] => Ingredient Object
                        (
                            [id] => 4
                            [name] => mackerel
                            [_table] => ingredient
                            [_primarykey] => id
                            [_fields] => Array
                                (
                                    [0] => id
                                    [1] => name
                                )

                        )

                )

        )

    [1] => Food Object
        (
            [id] => 6
            [name] => Wan Tan Mee
            [description] => Wonton noodle or wantan mee is a Cantonese noodle dish which is popular in Hong Kong, Malaysia, and Singapore.
            [location] => Malaysia
            [food_type_id] => 1
            [_table] => food
            [_primarykey] => id
            [_fields] => Array
                (
                    [0] => id
                    [1] => name
                    [2] => description
                    [3] => location
                    [4] => food_type_id
                )

            [Ingredient] => Array
                (
                    [0] => Ingredient Object
                        (
                            [id] => 1
                            [name] => water
                            [_table] => ingredient
                            [_primarykey] => id
                            [_fields] => Array
                                (
                                    [0] => id
                                    [1] => name
                                )

                        )

                    [1] => Ingredient Object
                        (
                            [id] => 2
                            [name] => oil
                            [_table] => ingredient
                            [_primarykey] => id
                            [_fields] => Array
                                (
                                    [0] => id
                                    [1] => name
                                )

                        )

                )

        )

    [2] => Food Object
        (
            [id] => 7
            [name] => Bak Kut Teh
            [description] => A Chinese soup popularly served in Malaysia, Singapore originated in Klang valley. Usually served with pork but sometimes seafood & even vegetarian style
            [location] => Malaysia
            [food_type_id] => 3
            [_table] => food
            [_primarykey] => id
            [_fields] => Array
                (
                    [0] => id
                    [1] => name
                    [2] => description
                    [3] => location
                    [4] => food_type_id
                )

            [Ingredient] => Array
                (
                    [0] => Ingredient Object
                        (
                            [id] => 1
                            [name] => water
                            [_table] => ingredient
                            [_primarykey] => id
                            [_fields] => Array
                                (
                                    [0] => id
                                    [1] => name
                                )

                        )

                    [1] => Ingredient Object
                        (
                            [id] => 14
                            [name] => bak kut teh herbs
                            [_table] => ingredient
                            [_primarykey] => id
                            [_fields] => Array
                                (
                                    [0] => id
                                    [1] => name
                                )

                        )

                    [2] => Ingredient Object
                        (
                            [id] => 15
                            [name] => Chinese white cabbage
                            [_table] => ingredient
                            [_primarykey] => id
                            [_fields] => Array
                                (
                                    [0] => id
                                    [1] => name
                                )

                        )

                    [3] => Ingredient Object
                        (
                            [id] => 23
                            [name] => garlic
                            [_table] => ingredient
                            [_primarykey] => id
                            [_fields] => Array
                                (
                                    [0] => id
                                    [1] => name
                                )

                        )

                )

        )

    [3] => Food Object
        (
            [id] => 4
            [name] => Nasi Lemak
            [description] => A kind of rice made with coconut milk
            [location] => Malaysia
            [food_type_id] => 4
            [_table] => food
            [_primarykey] => id
            [_fields] => Array
                (
                    [0] => id
                    [1] => name
                    [2] => description
                    [3] => location
                    [4] => food_type_id
                )

            [Ingredient] => Array
                (
                    [0] => Ingredient Object
                        (
                            [id] => 9
                            [name] => coconut milk
                            [_table] => ingredient
                            [_primarykey] => id
                            [_fields] => Array
                                (
                                    [0] => id
                                    [1] => name
                                )

                        )

                    [1] => Ingredient Object
                        (
                            [id] => 11
                            [name] => rice
                            [_table] => ingredient
                            [_primarykey] => id
                            [_fields] => Array
                                (
                                    [0] => id
                                    [1] => name
                                )

                        )

                    [2] => Ingredient Object
                        (
                            [id] => 22
                            [name] => ikan bilis
                            [_table] => ingredient
                            [_primarykey] => id
                            [_fields] => Array
                                (
                                    [0] => id
                                    [1] => name
                                )

                        )

                )

        )

    [4] => Food Object
        (
            [id] => 14
            [name] => Ban Mian
            [description] => A type of delicious noodles which is popular in KL
            [location] => Malaysia
            [food_type_id] => 1
            [_table] => food
            [_primarykey] => id
            [_fields] => Array
                (
                    [0] => id
                    [1] => name
                    [2] => description
                    [3] => location
                    [4] => food_type_id
                )

            [Ingredient] => Array
                (
                    [0] => Ingredient Object
                        (
                            [id] => 22
                            [name] => ikan bilis
                            [_table] => ingredient
                            [_primarykey] => id
                            [_fields] => Array
                                (
                                    [0] => id
                                    [1] => name
                                )

                        )

                )

        )

    [5] => Food Object
        (
            [id] => 26
            [name] => test
            [description] => delicious food
            [location] => sweden
            [food_type_id] => 3
            [_table] => food
            [_primarykey] => id
            [_fields] => Array
                (
                    [0] => id
                    [1] => name
                    [2] => description
                    [3] => location
                    [4] => food_type_id
                )

            [Ingredient] => Array
                (
                    [0] => Ingredient Object
                        (
                            [id] => 24
                            [name] => soy
                            [_table] => ingredient
                            [_primarykey] => id
                            [_fields] => Array
                                (
                                    [0] => id
                                    [1] => name
                                )

                        )

                )

        )

)

BACK TO LAST PAGE