Many things can go wrong there because of the exhotic setup. I'd suggest working with mappings with XML/YML first and then converting them to pure PHP once you are sure about what you are doing and what they should look like.
Also, try different hydration modes when querying. Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/ On 3 February 2014 15:07, Nima Sadjadi <[email protected]> wrote: > Yes they are according to my DB. But I did not yet set OneToOne, OneToMany > etc. Just want to run a simple query to test. I am not insisting to use > NativeSql and as you see I also tried to use Dql but no results returned > but I checked Where clause and one result is expected. Please advice what > wrong I did and how can I use just basic/simple dql as the one I used has > no return! > در 2014 2 3 14:56، "Marco Pivetta" <[email protected]> نوشت: > > Uhhh... Why are you jumping forward to NativeSQL already? That kinda >> defeats the advantage of using the ORM almost completely, at least for >> those simple queries. >> >> Did you validate your mappings first? Are they in sync with your DB? >> >> Marco Pivetta >> >> http://twitter.com/Ocramius >> >> http://ocramius.github.com/ >> >> >> On 3 February 2014 14:29, Nima Sadjadi <[email protected]> wrote: >> >>> Yes, when I added >>> protected $clientId; >>> the error message I said in prev. email is fixed and client_id coloumn >>> exists on prefix_clients table. Now I need to run a simple NativeSQL >>> to see if it works, >>> I have this: >>> >>> <?php >>> >>> require_once "bootstrap.php"; >>> require_once "entities/clients.php"; >>> >>> use Doctrine\ORM\Query\ResultSetMapping; >>> >>> $rsm = new Doctrine\ORM\Query\ResultSetMapping(); >>> // build rsm here >>> $qb = $em->createQueryBuilder(); >>> $query = $qb->getQuery(); >>> $query = $em->createNativeQuery('SELECT first_name FROM prefix_clients >>> WHERE username = ?', $rsm); >>> $query->setParameter(1, 'blad'); >>> $array = $query->getArrayResult(); >>> print_r($array); >>> >>> I get a blank array, no result returns. >>> >>> and if I use this: >>> >>> $class = $em->getClassMetadata('Entities\clients'); >>> //$class = $em->getMetadataFactory()->getMetadataFor('Entities\clients'); >>> >>> $rsm = new Doctrine\ORM\Query\ResultSetMapping; >>> $rsm->addEntityResult('Entities\clients', '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, 'evident'); >>> $users = $query->getResult(); >>> print_r($users); >>> >>> I get a blank array, no result returns. >>> >>> as about the addFieldResult, the second param is coloumn name and 3rd >>> param is fieldname that I've added protected $blah; in entity file. >>> Also I did check if WHERE clause and setParameter is valid and a >>> result is expected to be reurned but nothing returned, please advice. >>> >>> Please advice. >>> >>> -- >>> 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. >> > -- > 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.
