Zend Frameworkで多対多のテーブルを簡単に扱うの追記。

Zend Frameworkで多対多のテーブルを簡単に扱うの記事中で使用しているマッチテーブルの取得方法ですが

[php]
$products = new Products();
$bug_list = $products->find(10)->current()
->findManyToManyRowset(‘Bugs’, ‘BugsReports’);
[/php]

この指定だと、上手く拾ってくれないことがあるようです。
#/library以下にZend Frameworkのコーディング規約に則ったclass名をつけていないと駄目?

その場合は、インスタンスを直接渡せばOKです。上記の例でいえば、

[php]
$products = new Products();
$bugs = new Bugs();
$bugs_reports = new BugsReports();
$bug_list = $products->find(10)->current()
->findManyToManyRowset($bugs, $bugs_reports);
[/php]

とか、

[php]
$products = new Products();
$bug_list = $products->find(10)->current()
->findManyToManyRowset(new Bugs(), new BugsReports());
[/php]

とかですね。無事に取得できましたでしょうか。

関連する記事:

Powered by

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">