Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Critical Critical
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      Windows XP sp3

      Description

      i have query

      $q = Doctrine_Query::create()
      ->select('g.,gp.,st.,np.,v.,s.,max(gp.card_date) as md')
      ->from('gragdans as g')
      ->innerJoin('g.Pribs_ gp')
      ->leftJoin('gp.Streets_ st')
      ->leftJoin('gp.Viddocs_ v')
      ->leftJoin('gp.Sobits_ s')
      ->leftJoin('st.Npunkts_ np')
      ->where('g.grid in '.$idlst,1)
      ->orderby('fam')
      ->having('gp.card_date=md');

      When it runs i have error:

      <b>Fatal error</b>: Uncaught exception
      'Doctrine_Connection_Mysql_Exception' with message 'SQLSTATE[42S22]:
      Column not found: 1054 Unknown column 'md' in 'having clause'' in Z:
      \home\new\www\system\application\plugins\doctrine\lib\Doctrine
      \Connection.php:1082

      SQL for it looks like:

      SELECT g.grid AS g_grid, g.fam AS gfam, g.nam AS g_nam, g.otc AS
      g_otc, g.date_rogd AS gdate_rogd, g.gosgrid AS g_gosgrid,
      g.rogd_place AS g_rogd_place, g.pol AS g_pol, g.reg_date AS
      g_reg_date, g.deesp AS gdeesp, p.pribid AS p_pribid, p.grid AS
      p_grid, p.strid AS pstrid, p.hom AS phom, p.cor AS p_cor, p.kva
      AS p_kva, p.reg_date AS preg_date, p.vidid AS p_vidid, p.pas_ser
      AS p_pas_ser, p.pas_no AS ppas_no, p.org_name AS p_org_name,
      p.pas_date AS p_pas_date, p.sobid AS p_sobid, p.reg_expire AS
      p_reg_expire, p.card_date AS pcard_date, s.strid AS s_strid,
      s.npid AS s_npid, s.name AS sname, v.vidid AS v_vidid, v.name AS
      v_name, s2.sobid AS s2sobid, s2.cod_s AS s2_cod_s, s2.cod_oi AS
      s2_cod_oi, s2.name AS s2name, n.npid AS nnpid, n.name AS n_name,
      n.sid AS n_sid, MAX(p.card_date) AS p_0 FROM gragdans g INNER JOIN
      prib p ON g.grid = p.grid LEFT JOIN streets s ON p.strid = s.strid
      LEFT JOIN viddoc v ON p.vidid = v.vidid LEFT JOIN sobit s2 ON p.sobid
      = s2.sobid LEFT JOIN npunkt n ON s.npid = n.npid WHERE (g.grid in (4,
      13, 19, 20)) HAVING p.card_date=md ORDER BY g.fam

      But i need Query looks like:

      SELECT g.grid AS g_grid, g.fam AS gfam, g.nam AS g_nam, g.otc AS
      g_otc, g.date_rogd AS gdate_rogd, g.gosgrid AS g_gosgrid,
      g.rogd_place AS g_rogd_place, g.pol AS g_pol, g.reg_date AS
      g_reg_date, g.deesp AS gdeesp, p.pribid AS p_pribid, p.grid AS
      p_grid, p.strid AS pstrid, p.hom AS phom, p.cor AS p_cor, p.kva
      AS p_kva, p.reg_date AS preg_date, p.vidid AS p_vidid, p.pas_ser
      AS p_pas_ser, p.pas_no AS ppas_no, p.org_name AS p_org_name,
      p.pas_date AS p_pas_date, p.sobid AS p_sobid, p.reg_expire AS
      p_reg_expire, p.card_date AS pcard_date, s.strid AS s_strid,
      s.npid AS s_npid, s.name AS sname, v.vidid AS v_vidid, v.name AS
      v_name, s2.sobid AS s2sobid, s2.cod_s AS s2_cod_s, s2.cod_oi AS
      s2_cod_oi, s2.name AS s2name, n.npid AS nnpid, n.name AS n_name,
      n.sid AS n__sid, MAX(p.card_date) AS md FROM gragdans g INNER JOIN
      prib p ON g.grid = p.grid LEFT JOIN streets s ON p.strid = s.strid
      LEFT JOIN viddoc v ON p.vidid = v.vidid LEFT JOIN sobit s2 ON p.sobid
      = s2.sobid LEFT JOIN npunkt n ON s.npid = n.npid WHERE (g.grid in (4,
      13, 19, 20)) group by fam HAVING p.card_date=md

      This query run fine and give me what i need.

      Doctrine dont use 'md' alias instead it convert it to 'p__0'

        Activity

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            Vasiliy Altunin
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: