foreach在cakephp中检索数据

时间:2018-03-15 06:21:20

标签: php arrays cakephp foreach cakephp-2.0

我想在我的视图中显示所有配方数据,所以当我点击配方数据时,我将得到整个数组。

我在这里很难混淆如何在我的视图部分中获取此数据

[Recipe] => Array
    (
        [id] => 1
        [name] => test
        [desc] => test
        [makes] => 1
        [created_by] => 1
        [is_deleted] => 0
        [created_date] => 2018-03-14 13:09:43
    )

[RecipeCategory] => Array
    (
        [0] => Array
            (
                [id] => 3
                [recipe_id] => 1
                [categories_id] => 3
                [created_on] => 2018-03-14 13:17:01
                [Category] => Array
                    (
                        [id] => 3
                        [category_name] => Kitchen
                        [is_ingredient] => 1
                        [created_by] => 1
                        [is_default] => 1
                        [created_on] => 2018-03-14 09:32:01
                    )

            )

        [1] => Array
            (
                [id] => 4
                [recipe_id] => 1
                [categories_id] => 7
                [created_on] => 2018-03-14 13:17:01
                [Category] => Array
                    (
                        [id] => 7
                        [category_name] => sfsd
                        [is_ingredient] => 0
                        [created_by] => 1
                        [is_default] => 0
                        [created_on] => 2018-03-14 13:09:43
                    )

            )

        [2] => Array
            (
                [id] => 5
                [recipe_id] => 1
                [categories_id] => 8
                [created_on] => 2018-03-14 13:17:01
                [Category] => Array
                    (
                        [id] => 8
                        [category_name] => fsdfsdf
                        [is_ingredient] => 0
                        [created_by] => 1
                        [is_default] => 0
                        [created_on] => 2018-03-14 13:09:43
                    )

            )

    )

[RecipeStep] => Array
    (
        [0] => Array
            (
                [id] => 2
                [recipe_id] => 1
                [desc] => 
                [created_on] => 2018-03-14 13:17:01
                [RecipeIngredient] => Array
                    (
                        [0] => Array
                            (
                                [id] => 2
                                [recipe_steps_id] => 2
                                [ingredients_id] => 1042
                                [qty] => 1
                                [unit] => each
                                [preparation] => tr5est
                                [created_on] => 2018-03-14 13:17:01
                            )

                    )

            )

    )

如何检索数据并在视图中显示

食谱类别:此处显示所有类别名称

RecipeIngredient:在此处显示所有配方成分名称

感谢您的帮助

0 个答案:

没有答案