0

私は、ユーザーモデル内の他のテーブルからデータを取得するために関数 find('list') を使用して固執したCakephpの新機能です。例私はユーザーモデルにグループのリストを取得させたいと思っていますが、グループにはテーブル「グループ」がありますが、グループコントローラーとグループモデルのphpファイルを作成したくありません。

    <?php
      //User model
       class User extends AppModel {

         public function getGroupList() {
            /* Here i want return list all group by use function find('list') 
             * but group has table name "groups" and i don't want use sql query string.
             * Note that group i don't create  files php in controller and model.
             */

         }

       } 
    ?>
4

1 に答える 1

1

グループコントローラーを作成したくないのはなぜですか? ケーキのように物事を行うと、多くの場合、人生が楽になります。

いずれの場合も、追加の SQL クエリ (または少なくとも結合) が必要になります。

于 2012-11-30T03:48:55.950 に答える