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?
 
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?
 
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?
 
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 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