• <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 按字段值排序

        时间:2024-04-15
            <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 按字段值排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何在 Zend 框架中使用子查询执行查询 下一篇:SQL Server 2005 是否具有等效于 MySql 的 ENUM 数据类型?

                  相关文章

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

                • <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>