0

如何通过 Doctrine ORM 获取具有重复名称的特定列?

我正在使用 Zend 制作的自定义引擎开发一个项目。问题是我在 2 个表(c_naslovi 和 c_sportovi)中有重复的列名

我可以重命名列吗?我该怎么做?我是学说新手,请回答 n00b 问题:)

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

1 回答 1

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 
于 2012-08-29T12:44:24.680 回答