奇怪的排序问题

浏览:120 发布日期:2018/12/08 分类:ThinkPHP5专区
Array
(
    [0] => Array
        (
            [lm_id] => 1
            [lm_module_id] => 1
            [lm_pid] => 0
            [lm_childid] => 
            [lm_childall] => 1
            [lm_deep] => 0
            [lm_name] => PHP
            [lm_pyname] => php
            [lm_px] => 10
            [lm_isouturl] => 0
            [lm_outurl] => 
            [lm_img] => 
            [lm_key] => 
            [lm_desc] => 
            [lm_page] => 20
            [level] => 1
            [html] => 
        )

    [1] => Array
        (
            [lm_id] => 2
            [lm_module_id] => 2
            [lm_pid] => 0
            [lm_childid] => 
            [lm_childall] => 2
            [lm_deep] => 0
            [lm_name] => JavaScript
            [lm_pyname] => js
            [lm_px] => 20
            [lm_isouturl] => 0
            [lm_outurl] => 
            [lm_img] => 
            [lm_key] => 
            [lm_desc] => 
            [lm_page] => 20
            [level] => 1
            [html] => 
        )

    [2] => Array
        (
            [lm_id] => 3
            [lm_module_id] => 2
            [lm_pid] => 0
            [lm_childid] => 
            [lm_childall] => 3
            [lm_deep] => 0
            [lm_name] => Html
            [lm_pyname] => html
            [lm_px] => 30
            [lm_isouturl] => 0
            [lm_outurl] => 
            [lm_img] => 
            [lm_key] => 
            [lm_desc] => 
            [lm_page] => 20
            [level] => 1
            [html] => 
        )

    [3] => Array
        (
            [lm_id] => 6
            [lm_module_id] => 0
            [lm_pid] => 0
            [lm_childid] => 
            [lm_childall] => 6
            [lm_deep] => 0
            [lm_name] => C#
            [lm_pyname] => cs
            [lm_px] => 40
            [lm_isouturl] => 0
            [lm_outurl] => 
            [lm_img] => 
            [lm_key] => 
            [lm_desc] => 
            [lm_page] => 20
            [level] => 1
            [html] => 
        )

    [4] => Array
        (
            [lm_id] => 4
            [lm_module_id] => 2
            [lm_pid] => 0
            [lm_childid] => 
            [lm_childall] => 4
            [lm_deep] => 0
            [lm_name] => 生活随记
            [lm_pyname] => life
            [lm_px] => 200
            [lm_isouturl] => 0
            [lm_outurl] => 
            [lm_img] => 
            [lm_key] => 
            [lm_desc] => 
            [lm_page] => 20
            [level] => 1
            [html] => 
        )

    [5] => Array
        (
            [lm_id] => 5
            [lm_module_id] => 0
            [lm_pid] => 0
            [lm_childid] => 
            [lm_childall] => 5
            [lm_deep] => 0
            [lm_name] => 记录
            [lm_pyname] => jilu
            [lm_px] => 300
            [lm_isouturl] => 0
            [lm_outurl] => 
            [lm_img] => 
            [lm_key] => 
            [lm_desc] => 
            [lm_page] => 5
            [level] => 1
            [html] => 
        )

)
循环的html结构是:<li><a class="tpt-nav-li" href="http://localhost:9200/lm/jilu.html">记录</a><ul class="tpt-nav-ul"></ul></li>
            <li><a class="tpt-nav-li" href="http://localhost:9200/lm/life.html">生活随记</a><ul class="tpt-nav-ul"></ul></li>
            <li><a class="tpt-nav-li" href="http://localhost:9200/lm/cs.html">C#</a><ul class="tpt-nav-ul"></ul></li>
            <li><a class="tpt-nav-li" href="http://localhost:9200/lm/html.html">Html</a><ul class="tpt-nav-ul"></ul></li>
            <li><a class="tpt-nav-li" href="http://localhost:9200/lm/js.html">JavaScript</a><ul class="tpt-nav-ul"></ul></li>
            <li><a class="tpt-nav-li" href="http://localhost:9200/lm/php.html">PHP</a><ul class="tpt-nav-ul"></ul></li>
感觉反了啊/**
 * 获取所有栏目信息
 * @return array
 */
function getLmList($num = 10)
{
    $cacheName = "getLmList-{$num}";
    $list = [];
    if (Cache::has($cacheName)) {
        $list = Cache::get($cacheName);
    } else {
        $list = Db::name('lm')->order(['lm_px' => 'ASC', 'lm_id' => 'DESC'])->limit($num)->select();
        if (!empty($list)) {
            Cache::tag('getLmList')->set($cacheName, $list, 3600 * 24 * 10);
        }
    }
    print_r($list);
    return $list;
}
如果我把lm_px=>DESC的话,就html结果对了,打印又错了,我哪里写错了么?
最佳答案
评论( 相关
后面还有条评论,点击查看>>