Home  >  Q&A  >  body text

Omission error in thinkphp6.0 rapid development manual (case version)

Database chain operation [10. Template paging example]

//Error

$right = $list->toArray();

//Correct

$right = $list->toArray()["data"];

迷心兔迷心兔1732 days ago1237

reply all(16)I'll reply

  • 查无此人

    查无此人2020-02-13 17:13:43

    $right = $list->toArray();

    I’ve seen this and it’s no problem. No need to add another layer of ["data"];

    Error, please send a screenshot for me to take a look at.

    reply
    0
  • 迷心兔

    I can't insert a picture into my reply. I'll put it online and you can click on the link. https://blog.csdn.net/mixintu/article/details/104302187

    迷心兔 · 2020-02-13 20:37:58
    迷心兔

    This index method has been modified several times. Do you have all the code?

    迷心兔 · 2020-02-13 20:42:01
    查无此人

    $right = $list->toArray(); This is indeed no problem, as is the image you uploaded. The problem lies in: the paginate function requires one more layer. Still no problem, the return values ​​of the two functions paginate and select are different.

    查无此人 · 2020-02-14 14:46:14
    迷心兔

    Not modified: In the console: 'status' => isset($param['status']) ? $param['status'] : 0,//This is 0, I reported an error today In view: {if $right_v['status']==1}on{else/}off{/if} After modification: In the model: public function getStatusAttr($v){ $status = [ 1=>'Open', 2=>'Close' ]; return $status[$v]; } In the console: 'status' => isset($param['status']) ? $param['status'] : 1,//No error will be reported in this way In view: {$right_v['status']}

    迷心兔 · 2020-02-14 15:41:12
    迷心兔

    The paginate function does have one more layer. Directly use $right = $list->toArray(); There is an error in traversal in my code, hahaha, I don’t know why. In the end I still used your code in the model

    迷心兔 · 2020-02-14 15:43:33
    迷心兔

    Sorry, I responded to your content by carriage return and line change, but the content of the reply was all in one piece.

    迷心兔 · 2020-02-14 15:44:53
    迷心兔

    Oh, and one more thing: You can find this [view code: edit.html] in [thinkphp6.0 request], there are three edit.html [should be edit.html, add.html, index.html]

    迷心兔 · 2020-02-14 15:51:54
    查无此人

    Well, just solve it. My carriage return and line feed also have no effect.

    查无此人 · 2020-02-14 21:40:55
    迷心兔

    In my code, there is a small bug in the add page, [No change: ] [Changed]

    迷心兔 · 2020-02-15 00:48:03
    迷心兔

    [No change: option value="0">CloseClose

    迷心兔 · 2020-02-15 00:49:17
    迷心兔

    The first two replies are incomplete. Sorry, you can check the link: https://blog.csdn.net/mixintu/article/details/104302187

    迷心兔 · 2020-02-15 01:01:36
    查无此人

    OK, modified

    查无此人 · 2020-02-15 14:49:50
    迷心兔

    Could you please tell me how you write to switch [content on the right]? I wrote some myself today: https://blog.csdn.net/mixintu/article/details/104302187

    迷心兔 · 2020-02-15 18:13:40
    迷心兔

    I used the built-in paginate function today and it can output data, but the pagination code does not appear in some templates.

    迷心兔 · 2020-03-02 14:39:01
    查无此人

    You asked again, but I didn’t see it. You can add me. Can't reply in time here.

    查无此人 · 2020-03-19 11:40:00
  • Cancelreply