2
Doctrineで配列の配列を取得するのはどういうことでしょうか?Symfony Doctrineは配列として国を取得します
この例では、国を配列にする必要があります。
$user['country']['name']
or
$user['country']['cid']
私の現在の要求:
$query = $this->createQueryBuilder('u')
->select('u')
->getQuery();
return $query->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY);
私はここでしか同上のを取得します。 YMLと
Doctrineのエンティティ:
ユーザー:
TestBundle\Entity\User:
type: entity
table: user
repositoryClass: TestBundle\Entity\UserRepository
id:
uid:
type: integer
nullable: false
unsigned: true
id: true
generator:
strategy: IDENTITY
fields:
firstname:
type: string
nullable: true
length: 255
fixed: false
lastname:
type: string
nullable: true
length: 255
fixed: false
email:
type: string
nullable: true
length: 255
fixed: false
oneToOne:
country:
targetEntity: Country
joinColumn:
name: country
referencedColumnName: cid
lifecycleCallbacks: { }
国:
私は周りに10 000オブジェクトのを持っているので、それは、私の例では速度に依存TestBundle\Entity\Country:
type: entity
table: country
repositoryClass: TestBundle\Entity\CountryRepository
id:
cid:
type: integer
nullable: false
unsigned: false
id: true
generator:
strategy: IDENTITY
fields:
cid:
type: integer
nullable: true
unsigned: false
options:
default: 0
name:
type: string
nullable: true
length: 255
fixed: false
lifecycleCallbacks: { }
。
別の解決策は、など、「グループ」
それは役に立ちましたか?それともあなたの質問にまだ何かが開いていますか? –