php - MySQL User defined variable within Doctrine and Symfony -


i have following doctrine statement works fine.

$query = $this->createquery('r')             ->select('u.id, concat(u.first_name, " ", left(u.last_name,1)) full_name, u.first_name, u.last_name, u.gender, r.run_time')             ->innerjoin('r.challengeuser u')             ->orderby('run_time')             ->execute(array(), doctrine::hydrate_array_shallow); 

i need add row count this. know raw sql can this;

set @rank=0; select @rank:=@rank+1 rank, u.id, u.first_name ....etc 

so question is, how can run symfony 1.4 , doctrine? using mysql project.


edit... figured out..

doctrine_manager::getinstance()->getcurrentconnection()->standalonequery('set @rank=0;')->execute();  $query = $this->createquery('r')             ->select('r.run_time, @rank:=@rank+1 rank, r.user_id, concat(u.first_name, " ", left(u.last_name,1)) full_name, u.first_name, u.last_name, u.gender')             ->leftjoin('r.challengeuser u')             ->orderby('run_time')             ->execute(array(), doctrine::hydrate_array_shallow); 

add standalone query in set variable, , swap inner join left join.

if using mysql, , no switches other dbms foreseen, maybe try

$query = $this->createquery('r')             ->select('count(u.id) rank, u.id, concat(u.first_name, " ", left(u.last_name,1)) full_name, u.first_name, u.last_name, u.gender, r.run_time')             ->innerjoin('r.challengeuser u')             ->orderby('run_time')             ->execute(array(), doctrine::hydrate_array); 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -