• <tfoot id='O5YhQ'></tfoot>
    1. <i id='O5YhQ'><tr id='O5YhQ'><dt id='O5YhQ'><q id='O5YhQ'><span id='O5YhQ'><b id='O5YhQ'><form id='O5YhQ'><ins id='O5YhQ'></ins><ul id='O5YhQ'></ul><sub id='O5YhQ'></sub></form><legend id='O5YhQ'></legend><bdo id='O5YhQ'><pre id='O5YhQ'><center id='O5YhQ'></center></pre></bdo></b><th id='O5YhQ'></th></span></q></dt></tr></i><div id='O5YhQ'><tfoot id='O5YhQ'></tfoot><dl id='O5YhQ'><fieldset id='O5YhQ'></fieldset></dl></div>

      <small id='O5YhQ'></small><noframes id='O5YhQ'>

          <bdo id='O5YhQ'></bdo><ul id='O5YhQ'></ul>
        <legend id='O5YhQ'><style id='O5YhQ'><dir id='O5YhQ'><q id='O5YhQ'></q></dir></style></legend>
      1. 在 yii2 中使用 `with` 的嵌套关系

        Nested relations using `with` in yii2(在 yii2 中使用 `with` 的嵌套关系)
          <tbody id='2yZKG'></tbody>
      2. <small id='2yZKG'></small><noframes id='2yZKG'>

          • <legend id='2yZKG'><style id='2yZKG'><dir id='2yZKG'><q id='2yZKG'></q></dir></style></legend>

              <tfoot id='2yZKG'></tfoot>
              • <bdo id='2yZKG'></bdo><ul id='2yZKG'></ul>

                  <i id='2yZKG'><tr id='2yZKG'><dt id='2yZKG'><q id='2yZKG'><span id='2yZKG'><b id='2yZKG'><form id='2yZKG'><ins id='2yZKG'></ins><ul id='2yZKG'></ul><sub id='2yZKG'></sub></form><legend id='2yZKG'></legend><bdo id='2yZKG'><pre id='2yZKG'><center id='2yZKG'></center></pre></bdo></b><th id='2yZKG'></th></span></q></dt></tr></i><div id='2yZKG'><tfoot id='2yZKG'></tfoot><dl id='2yZKG'><fieldset id='2yZKG'></fieldset></dl></div>
                  本文介绍了在 yii2 中使用 `with` 的嵌套关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  谁能告诉我,我有几个型号:一个Item有很多→属性,On Property有很多→特性我可以这样做:

                  Can someone tell me, I have several model: One Item has many → Properties, On Property has many → Characteristics I can do like this:

                  return Item::find()->where(['code' => $code])->with('properties')->asArray()->one();
                  

                  结果:

                  {
                    title: "Ванна чугунная Ностальжи 150 с ножками",
                    new: "0",
                    hit: "0",
                    recommend: "0",
                    properties: [
                    {
                      //lallala
                    },
                    {
                      //lallala
                    },
                    ]
                  }
                  

                  但我想要嵌套行(特征)在每个属性中我怎么能做那么优雅的方式?

                  But i want nested rows (Characteristics) in every property how can i do that much elegant way?

                  推荐答案

                  来自 Yii 使用数据库的指南:

                  您可以急切地加载深度嵌套的关系,例如 a.b.c.d.所有父关系都将被急切地加载.也就是说,当你使用 abcd 调用 with() 时,你会急切地加载 a, ab, >abcabcd.

                  You can eagerly load deeply nested relations, such as a.b.c.d. All parent relations will be eagerly loaded. That is, when you call with() using a.b.c.d, you will eagerly load a, a.b, a.b.c and a.b.c.d.

                  所以使用properties.characteristics:

                  return Item::find()->where(['code' => $code])->with('properties.characteristics')->asArray()->one()
                  

                  这篇关于在 yii2 中使用 `with` 的嵌套关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Is Joomla 2.5 much faster than Joomla 1.5 Querywise(Joomla 2.5 比 Joomla 1.5 Querywise 快得多吗)
                  How to share Joomla login session from one joomla website to one ASP.Net MVC website(如何将 Joomla 登录会话从一个 joomla 网站共享到一个 ASP.Net MVC 网站)
                  htaccess redirect root to subdirectory but allow index.php in root AND query strings to function(htaccess 将根重定向到子目录,但允许根和查询字符串中的 index.php 起作用)
                  Joomla include database functions(Joomla 包含数据库功能)
                  nl2br() not working when displaying SQL results(显示 SQL 结果时 nl2br() 不起作用)
                  Joomla 2.5 JFactory::getSession(); seems to be caching in firefox(Joomla 2.5 JFactory::getSession();似乎在 Firefox 中缓存)

                        <legend id='ekqEd'><style id='ekqEd'><dir id='ekqEd'><q id='ekqEd'></q></dir></style></legend>

                          <tbody id='ekqEd'></tbody>

                        • <small id='ekqEd'></small><noframes id='ekqEd'>

                            <bdo id='ekqEd'></bdo><ul id='ekqEd'></ul>

                            <i id='ekqEd'><tr id='ekqEd'><dt id='ekqEd'><q id='ekqEd'><span id='ekqEd'><b id='ekqEd'><form id='ekqEd'><ins id='ekqEd'></ins><ul id='ekqEd'></ul><sub id='ekqEd'></sub></form><legend id='ekqEd'></legend><bdo id='ekqEd'><pre id='ekqEd'><center id='ekqEd'></center></pre></bdo></b><th id='ekqEd'></th></span></q></dt></tr></i><div id='ekqEd'><tfoot id='ekqEd'></tfoot><dl id='ekqEd'><fieldset id='ekqEd'></fieldset></dl></div>
                            <tfoot id='ekqEd'></tfoot>