简体   繁体   中英

How to get specific column that is duplicated in Doctrine ORM?

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();

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 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM