0

how can I get specific column with duplicated name via Doctrine ORM?

I'm working on a project using custom engine that is made in Zend. The problem is I got duplicated column names in 2 tables (c_naslovi and c_sportovi)

Can I do column rename maybe? How can I do it? I'm new in doctrine, sry on n00b question :)

$q = new Doctrine_RawSql();
        $q->select("{p.*}, {n.*}, {np.*}, {sp.*}")
            ->from("c_ponude p LEFT JOIN c_naslovi n ON p.NaslovID = n.NaslovID 
                LEFT JOIN c_nasloviprijevodi np ON np.NaslovID = n.NaslovID 
                LEFT JOIN c_sportovi sp ON n.SportID = sp.SportID")
            ->where("p.DatumVrijemeOdigravanja > NOW()")
            ->andWhere("(p.IndikatorPonude = 'P' OR p.IndikatorPonude = 'H')")
            ->andWhere("p.KoeficijentZbroj > 0")
            ->andWhere("p.BrojPonude = ?", array($offerId))
            ->orderby("p.RedniBrojRazrade")         
            ->addComponent("p", "cPonude p")
            ->addComponent("n", "p.cNaslovi n")
            ->addComponent("np", "n.cNasloviprijevodi np")
            ->addComponent("sp", "n.cSportovi sp");

    $offer = $q->execute();
Tom
  • 679
  • 1
  • 12
  • 29
  • If I understand your question correctly, You can solve this by adding aliases, but `Doctrine` uses it's own aliases for the query, so it will automatically rename the duplicate columns. Something like `c_naslovi.duplicate_column as c_0` and `c_sportovi.duplicate_column as s_0` – Sanjay Aug 29 '12 at 07:36
  • thanks on your answer... Didn't know that. I found out that I also got error in query. After I fix it will look up for duplicates. Tnx once again – Tom Aug 29 '12 at 07:46

1 Answers1

0

If I understand your question correctly, You can solve this by adding aliases, but Doctrine uses it's own aliases for the query.

So it will automatically rename the duplicate columns. Something like:

c_naslovi.duplicate_column as c_0 
c_sportovi.duplicate_column as s_0 
Sanjay
  • 1,570
  • 1
  • 13
  • 30