質問編集履歴
1
質問内容の変更
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,38 +1,30 @@
|
|
1
|
-
|
1
|
+
http://symfony.com/doc/current/reference/forms/types/entity.html#using-a-custom-query-for-the-entities
|
2
2
|
|
3
|
-
$builder
|
4
|
-
// 商品規格情報
|
5
|
-
->add('class', 'admin_product_class', array(
|
6
|
-
'mapped' => false,
|
7
|
-
))
|
8
|
-
// 基本情報
|
9
|
-
->add('name', 'text', array(
|
10
|
-
'label' => '商品名',
|
11
|
-
'constraints' => array(
|
12
|
-
new Assert\NotBlank(),
|
13
|
-
),
|
14
|
-
))
|
15
|
-
->add('product_image', 'file', array(
|
16
|
-
'label' => '商品画像',
|
17
|
-
'multiple' => true,
|
18
|
-
'required' => false,
|
19
|
-
'mapped' => false,
|
20
|
-
))
|
21
|
-
|
3
|
+
https://github.com/EC-CUBE/ec-cube/blob/3.0.10/src/Eccube/Form/Type/ShippingMultipleItemType.php#L75</blockquote></div>
|
22
|
-
'label' => '商品説明',
|
23
|
-
))
|
24
|
-
->add('description_list', 'textarea', array(
|
25
|
-
'label' => '商品説明(一覧)',
|
26
|
-
'required' => false,
|
27
|
-
))
|
28
|
-
->add('Category', 'category', array(
|
29
|
-
'label' => '商品カテゴリ',
|
30
|
-
'multiple' => true,
|
31
|
-
'mapped' => false,
|
32
|
-
))
|
33
|
-
・・・
|
34
4
|
|
35
|
-
ここの商品カテゴリのところをカスタマイズすればよいと思うのですが
|
36
|
-
|
5
|
+
これらを参考にし、query_builderを使用して実現しようとしているのですが
|
37
6
|
|
7
|
+
'query_builder' => function (EntityRepository $er) use ($Customer) {
|
8
|
+
return $er->createQueryBuilder('ca')
|
9
|
+
->where('ca.Customer = :Customer')
|
10
|
+
->orderBy("ca.id", "ASC")
|
11
|
+
->setParameter('Customer', $Customer);
|
12
|
+
},
|
13
|
+
|
14
|
+
このようになっている場合、functionの後ろには何を記載しているのでしょうか?
|
15
|
+
createQueryBuilderを呼び出しているため
|
16
|
+
vendor\doctrine\orm\lib\Doctrine\ORMの
|
17
|
+
クラスを記載しているものと思いますが
|
18
|
+
|
19
|
+
createQueryBuilder自体が
|
20
|
+
EntityManager.phpとEntityRepository.phpにあるため
|
21
|
+
どちらを呼び出すのだろうと悩んでしまいました。
|
22
|
+
|
23
|
+
また、createQueryBuilderの後ろも''で囲われているもので
|
24
|
+
ここはテーブルの略称なのかな?と思うのでなんでもいいのかもしれませんが…
|
25
|
+
|
26
|
+
->where('ca.Customer = :Customer')
|
27
|
+
where句もどのように記載すればいいのか…
|
28
|
+
|
38
|
-
|
29
|
+
これらのヒントなどご教示いただけますと幸いです。
|
30
|
+
よろしくお願いいたします。
|