So if I have associations as OneToMany, ManyToMany .... Only then will 
generate Proxy class ?

On Thursday, 28 January 2016 02:40:22 UTC+2, Marco Pivetta wrote:
>
> Hi Krasimir,
>
> That query won't use any proxies or object hydration, as you are selecting 
> `p.title`, which is a single field. If `p` is an object with any kind of 
> association, simply selecting `->select('p')` will give you fully hydrated 
> objects with proxies for associations.
>
> Cheers,
>
> Marco Pivetta 
>
> http://twitter.com/Ocramius      
>
> http://ocramius.github.com/
>
> On 27 January 2016 at 22:33, Krasimir Nikolov <[email protected] 
> <javascript:>> wrote:
>
>> I have the following configuration
>>
>>      $isDevMode = \Config::get("DEBUG");
>>     self::$config = 
>> Setup::createAnnotationMetadataConfiguration(array(APP_PATH.'models'), 
>> $isDevMode, APP_PATH.'proxies');
>>
>>     // naming strategy
>>     $namingStrategy = new \DoctrineExtensions\CustomNamingStrategy();
>>     self::$config->setNamingStrategy($namingStrategy);
>>
>>     // database configuration parameters
>>     self::$conn = array(
>>         'url' => \Config::get('DB_DSN')
>>     );
>>
>>     self::$evm = new \Doctrine\Common\EventManager;
>>
>>     // Table Prefix
>>     $tablePrefix = new 
>> \DoctrineExtensions\TablePrefix(\Config::get('TABLE_PREFIX'));
>>     self::$evm->addEventListener(Events::loadClassMetadata, $tablePrefix);
>>     self::$entityManager = EntityManager::create(self::$conn, 
>> self::$config, self::$evm);
>>
>> From Doctrine 2 Documentation which I understand, this should be generate 
>> Proxy classes in `APP_PATH.'proxies'` folder ( when `$isDevMode` is true. 
>> This should happen automatically).
>>
>> Unfortunately it doesn't automatically generated classes. I don't know 
>> what the reason. However I generated these classes manually by using the 
>> following command `php vendor/bin/doctrine orm:generate-proxies`. Classes 
>> are generated and already exist in the folder. In order to try Proxy 
>> classes i wrote the following lines:
>>
>>     $qq = $this->repositoryPages
>>     ->createQueryBuilder('p')
>>     ->select('p.title')
>>     ->where('p.id = :id')
>>     ->setParameter('id', 6)
>>     ->getQuery()->getResult();
>>     var_dump($qq);
>>
>> Unfortunately for me this returns an associative array
>>
>>     array (size=1)
>>     0 => 
>>        array (size=1)
>>          'title' => string 'Welcome' (length=7)
>>
>> What is wrong and what I need to do to get the object ?
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "doctrine-user" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> Visit this group at https://groups.google.com/group/doctrine-user.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to