<i id='Q5Sit'><tr id='Q5Sit'><dt id='Q5Sit'><q id='Q5Sit'><span id='Q5Sit'><b id='Q5Sit'><form id='Q5Sit'><ins id='Q5Sit'></ins><ul id='Q5Sit'></ul><sub id='Q5Sit'></sub></form><legend id='Q5Sit'></legend><bdo id='Q5Sit'><pre id='Q5Sit'><center id='Q5Sit'></center></pre></bdo></b><th id='Q5Sit'></th></span></q></dt></tr></i><div id='Q5Sit'><tfoot id='Q5Sit'></tfoot><dl id='Q5Sit'><fieldset id='Q5Sit'></fieldset></dl></div>

      <small id='Q5Sit'></small><noframes id='Q5Sit'>

        <bdo id='Q5Sit'></bdo><ul id='Q5Sit'></ul>
      <legend id='Q5Sit'><style id='Q5Sit'><dir id='Q5Sit'><q id='Q5Sit'></q></dir></style></legend>
      <tfoot id='Q5Sit'></tfoot>
      1. 带有 mysql 变量的 Mysql 查询在 Zend Framework 1 中不起作用

        Mysql Query with mysql variable not working in Zend Framework 1(带有 mysql 变量的 Mysql 查询在 Zend Framework 1 中不起作用)
          <bdo id='pIOHd'></bdo><ul id='pIOHd'></ul>

            <small id='pIOHd'></small><noframes id='pIOHd'>

              <tbody id='pIOHd'></tbody>

                <i id='pIOHd'><tr id='pIOHd'><dt id='pIOHd'><q id='pIOHd'><span id='pIOHd'><b id='pIOHd'><form id='pIOHd'><ins id='pIOHd'></ins><ul id='pIOHd'></ul><sub id='pIOHd'></sub></form><legend id='pIOHd'></legend><bdo id='pIOHd'><pre id='pIOHd'><center id='pIOHd'></center></pre></bdo></b><th id='pIOHd'></th></span></q></dt></tr></i><div id='pIOHd'><tfoot id='pIOHd'></tfoot><dl id='pIOHd'><fieldset id='pIOHd'></fieldset></dl></div>

              1. <tfoot id='pIOHd'></tfoot>

                <legend id='pIOHd'><style id='pIOHd'><dir id='pIOHd'><q id='pIOHd'></q></dir></style></legend>

                1. 本文介绍了带有 mysql 变量的 Mysql 查询在 Zend Framework 1 中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  Zend 配置是:resources.db.adapter = "pdo_mysql"

                  Zend config is : resources.db.adapter = "pdo_mysql"

                  得到Message: SQLSTATE[HY000]: General error

                  $db = Zend_Db_Table::getDefaultAdapter();
                          $db->setFetchMode(Zend_Db::FETCH_ASSOC);       
                  
                  
                          $qry =  $db->fetchAll(" SET @rank = 0 ;
                                                  SELECT
                                                     @rank := @rank +1 AS rank,
                                                      SUM(user_scoring_data.user_points)  AS user_points,
                                                      league_team.user_id
                  
                                                  FROM league_team 
                                                  RIGHT JOIN user_scoring_data ON league_team.league_team_id = user_scoring_data.league_team_id
                  
                                                  WHERE league_id = '$league_id' GROUP BY user_scoring_data.league_team_id 
                                                  ORDER BY user_points DESC"
                                              );
                  

                  如果我删除 mysql 变量,它会起作用:

                  if I remove the mysql variable, it works:

                  $db->fetchAll("
                                                  SELECT
                                                      SUM(user_scoring_data.user_points)  AS user_points,
                                                      league_team.user_id
                  
                                                  FROM league_team 
                                                  RIGHT JOIN user_scoring_data ON league_team.league_team_id = user_scoring_data.league_team_id
                  
                                                  WHERE league_id = '$league_id' GROUP BY user_scoring_data.league_team_id 
                                                  ORDER BY user_points DESC"
                                              );
                  

                  *注:查询直接在phpmyadmin中测试过,没有错误.

                  *Note: query was tested directly in phpmyadmin and has no errors.

                  推荐答案

                  在 MySql 中设置变量似乎被认为是一个单独的查询.( fetch*() 不能处理多个调用)

                  It seems setting a variable in MySql is considered a separate query. ( fetch*() cannot handle multiple calls)

                  所以对于那些有这种问题的人:

                  so for those with this kind of issue:

                  $db->query("SET @rank = 0 ;");
                  
                  $db->fetchAll("SELECT
                                                     @rank := @rank +1 AS rank,
                                                      SUM(user_scoring_data.user_points)  AS user_points,
                                                      league_team.user_id
                  
                                                  FROM league_team 
                                                  RIGHT JOIN user_scoring_data ON league_team.league_team_id = user_scoring_data.league_team_id
                  
                                                  WHERE league_id = '$league_id' GROUP BY user_scoring_data.league_team_id 
                                                  ORDER BY user_points DESC"
                                              );
                  

                  这篇关于带有 mysql 变量的 Mysql 查询在 Zend Framework 1 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  What does SQL clause quot;GROUP BY 1quot; mean?(SQL 子句“GROUP BY 1是什么意思?意思是?)
                  MySQL groupwise MAX() returns unexpected results(MySQL groupwise MAX() 返回意外结果)
                  MySQL SELECT most frequent by group(MySQL SELECT 按组最频繁)
                  Why Mysql#39;s Group By and Oracle#39;s Group by behaviours are different(为什么 Mysql 的 Group By 和 Oracle 的 Group by 行为不同)
                  MySQL GROUP BY DateTime +/- 3 seconds(MySQL GROUP BY DateTime +/- 3 秒)
                  MySQL cumulative sum grouped by date(按日期分组的 MySQL 累计总和)

                  <tfoot id='iE1bX'></tfoot>
                    <i id='iE1bX'><tr id='iE1bX'><dt id='iE1bX'><q id='iE1bX'><span id='iE1bX'><b id='iE1bX'><form id='iE1bX'><ins id='iE1bX'></ins><ul id='iE1bX'></ul><sub id='iE1bX'></sub></form><legend id='iE1bX'></legend><bdo id='iE1bX'><pre id='iE1bX'><center id='iE1bX'></center></pre></bdo></b><th id='iE1bX'></th></span></q></dt></tr></i><div id='iE1bX'><tfoot id='iE1bX'></tfoot><dl id='iE1bX'><fieldset id='iE1bX'></fieldset></dl></div>
                      <tbody id='iE1bX'></tbody>

                      <bdo id='iE1bX'></bdo><ul id='iE1bX'></ul>
                        <legend id='iE1bX'><style id='iE1bX'><dir id='iE1bX'><q id='iE1bX'></q></dir></style></legend>
                          1. <small id='iE1bX'></small><noframes id='iE1bX'>