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

Ingredient with Food

Result: SQL executed.

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

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

            [Food] => Array
                (
                    [0] => 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
                                )

                        )

                )

        )

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

            [Food] => Array
                (
                    [0] => 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
                                )

                        )

                )

        )

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

            [Food] => Array
                (
                    [0] => 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
                                )

                        )

                    [1] => 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
                                )

                        )

                )

        )

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

            [Food] => 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
                                )

                        )

                    [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
                                )

                        )

                    [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
                                )

                        )

                )

        )

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

            [Food] => 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
                                )

                        )

                )

        )

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

            [Food] => 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
                                )

                        )

                )

        )

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

            [Food] => Array
                (
                    [0] => 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
                                )

                        )

                )

        )

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

            [Food] => Array
                (
                    [0] => 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
                                )

                        )

                )

        )

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

            [Food] => Array
                (
                    [0] => 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
                                )

                        )

                )

        )

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

            [Food] => Array
                (
                    [0] => 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
                                )

                        )

                )

        )

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

            [Food] => Array
                (
                    [0] => 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
                                )

                        )

                )

        )

)

BACK TO LAST PAGE