• <small id='Hkftp'></small><noframes id='Hkftp'>

      <tfoot id='Hkftp'></tfoot>
    1. <legend id='Hkftp'><style id='Hkftp'><dir id='Hkftp'><q id='Hkftp'></q></dir></style></legend>
    2. <i id='Hkftp'><tr id='Hkftp'><dt id='Hkftp'><q id='Hkftp'><span id='Hkftp'><b id='Hkftp'><form id='Hkftp'><ins id='Hkftp'></ins><ul id='Hkftp'></ul><sub id='Hkftp'></sub></form><legend id='Hkftp'></legend><bdo id='Hkftp'><pre id='Hkftp'><center id='Hkftp'></center></pre></bdo></b><th id='Hkftp'></th></span></q></dt></tr></i><div id='Hkftp'><tfoot id='Hkftp'></tfoot><dl id='Hkftp'><fieldset id='Hkftp'></fieldset></dl></div>

        • <bdo id='Hkftp'></bdo><ul id='Hkftp'></ul>
      1. Zend_Db 按字段值排序

        Zend_Db order by field Value(Zend_Db 按字段值排序)
            <tbody id='8ctWy'></tbody>

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

                <small id='8ctWy'></small><noframes id='8ctWy'>

                  <legend id='8ctWy'><style id='8ctWy'><dir id='8ctWy'><q id='8ctWy'></q></dir></style></legend>
                • 本文介绍了Zend_Db 按字段值排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在使用这个从模型输出选择菜单的内容:

                  I'm outputting the contents of a select menu from a model using this:

                  $select = $this->select();
                  $select->order('name');
                  return $this->fetchAll($select);
                  

                  但是,我想要做的是按特定值排序,然后按名称列排序.SQL 看起来像这样:

                  However, what i want to do is order by a specific value, and then by the name column. The SQL would look like this:

                  SELECT * FROM `names` ORDER BY `name` = 'SomeValue' DESC,`name`
                  

                  示例 SQL 代码:

                  CREATE TABLE IF NOT EXISTS `names` (
                    `id` int(11) NOT NULL auto_increment,
                    `name` varchar(100) NOT NULL,
                    PRIMARY KEY  (`id`)
                  ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ;
                  
                  INSERT INTO `names` (`id`, `name`) VALUES
                  (1, 'rob'),
                  (2, 'dave'),
                  (3, 'andy'),
                  (4, 'paul'),
                  (5, 'jason'),
                  (6, 'john');
                  
                  SELECT *
                  FROM `names`
                  ORDER BY `name` = 'john' DESC , `name`
                  

                  返回:

                  6   john
                  3   andy
                  2   dave
                  5   jason
                  4   paul
                  1   rob
                  

                  推荐答案

                  我相信这就是您要找的:

                  I believe this is what you are looking for:

                  $name = 'John';
                  $order = new Zend_Db_Expr($this->getAdapter()->quoteInto("name = ?", $name) ." DESC, `name`");
                  $select = $this->select();
                  $select->order($order);
                  return $this->fetchAll($select);
                  

                  这篇关于Zend_Db 按字段值排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  SQL query to group by day(按天分组的 SQL 查询)
                  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 按组最频繁)
                  Include missing months in Group By query(在 Group By 查询中包含缺失的月份)
                  Why Mysql#39;s Group By and Oracle#39;s Group by behaviours are different(为什么 Mysql 的 Group By 和 Oracle 的 Group by 行为不同)
                  • <small id='cqBaj'></small><noframes id='cqBaj'>

                        <tbody id='cqBaj'></tbody>
                      <tfoot id='cqBaj'></tfoot>

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