As about my question 3, in entity file I did change the primary table from
prefix_clients to clients as I just did setup table prefixing, but when
running a DQL it returns table not found error. As i said since table
prefix is set by end-user in config.php it should not be hard-coded in
entity file any more. So what can I do? If I edit it in entity file I get
error however i did setup prefix eventlistener. Please advice.
 در 2014 2 4 08:42، "Marco Pivetta" <[email protected]> نوشت:

> Sorry, my first answer came in blank because I apparently replied to it
> from my phone, which was in my pocket - now trying to figure out how many
> mails I've sent like that :-)
>
> On 3 February 2014 19:44, Parsifal <[email protected]> wrote:
>
>>
>> HI,
>>
>> I used:
>>
>> $query = $em->createQuery('SELECT u.username FROM Entities\clients u');
>> $users = $query->getResult();
>> print_r($users);
>>
>> Then:
>> ..
>>     [1] => Array
>>         (
>>             [username] => ksazkhdca
>>         )
>>
>> Wow! finally with the help of Marco and Hermann I got it worked! Thanks a
>> lot to them!
>>
>> Just a few questions then I'll be fine:
>> 1) In order to use PHP metadata files in /entities/ folder, this is my
>> job to write an autoloader()? or there is a built-in autoloader I may use?
>> if yes, how? or since the folder name is /entities/ autoloader loads them
>> by default?
>>
>
> There is no automagic autoloading process - you need to setup autoloading
> on your own. Composer can provide this functionality to you.
>
>
>>
>> 2) ApcCache, MemCache etc. are not installed in most of shared hostings
>> so my users may have problem so is it good to allow them to use
>> ArrayCache() if they don't have them installed?
>>
>
> Any Doctrine\Common\Cache\Cache implementation is fine, but ArrayCache
> will be very slow for production systems.
>
>
>>
>> 3) I am allowing users to set a table prefix in config.php during
>> installation, according to Guide I am using this in bootsrap.php:
>>
>> $evm = new Doctrine\Common\EventManager;
>> $tablePrefix = new
>> Doctrine\ORM\DoctrineExtensions\TablePrefix($db_prefix);
>> $evm->addEventListener(Doctrine\ORM\Events::loadClassMetadata,
>> $tablePrefix);
>> but the prefix is hard-coded in generated entity file as below:
>>
>> $metadata->setPrimaryTable(array(
>>    'name' => 'prefix_clients',
>>
>> How should I edit this line?
>>
>
> The metadata loading event is fired _after_ metadata has been loaded,
> therefore the TablePrefix listener will be able to work correctly.
>
>
>>
>> 4) In some cases I still need to use NativeQuery, I used the following 2
>> ways but not yet worked, please advice:
>>
>> a)
>> use Doctrine\ORM\Query\ResultSetMapping;
>> $rsm = new Doctrine\ORM\Query\ResultSetMapping();
>> $qb = $em->createQueryBuilder();
>> $query = $qb->getQuery();
>> $query = $em->createNativeQuery('SELECT*FROM prefix_clients', $rsm);
>> $array = $query->getArrayResult();
>> print_r($array);
>>
>> b)
>> $rsm = new Doctrine\ORM\Query\ResultSetMapping;
>> $rsm->addEntityResult('PrefixClients', 'u');
>> $rsm->addFieldResult('u', 'client_id', 'clientId');
>> $rsm->addFieldResult('u', 'first_name', 'firstName');
>> $query = $em->createNativeQuery('SELECT client_id, first_name FROM
>> prefix_clients WHERE username = ?', $rsm);
>> $query->setParameter(1, 'blah');
>> $users = $query->getResult();
>> print_r($users);
>>
>
> You need to debug into that, see
> http://codingkilledthecat.wordpress.com/2012/06/26/how-to-ask-for-programming-help/
>
>
>
> Marco Pivetta
>
> http://twitter.com/Ocramius
>
> http://ocramius.github.com/
>
>
> --
> 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 http://groups.google.com/group/doctrine-user.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
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 http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to