Omission error in thinkphp6.0 rapid development manual (case version)
迷心兔
迷心兔 2020-02-13 01:04:43
0
16
1240

Database chain operation [10. Template paging example]

//Error

$right = $list->toArray();

//Correct

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

迷心兔
迷心兔

reply all(1)
欧阳克

$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 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
    迷心兔 author 2020-02-13 20:37:58
  • reply This index method has been modified several times. Do you have all the code?
    迷心兔 author 2020-02-13 20:42:01
  • reply $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.
    查无此人 author 2020-02-14 14:46:14
  • reply Not modified: In the console: 'status' => isset($param['status']) ? $param['status'] : 0,//This is 0, I reported an error today In view: <td>{if $right_v['status']==1}on{else/}off{/if}</td> 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: <td>{$right_v['status']}</td>
    迷心兔 author 2020-02-14 15:41:12
  • reply 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
    迷心兔 author 2020-02-14 15:43:33
  • reply Sorry, I responded to your content by carriage return and line change, but the content of the reply was all in one piece.
    迷心兔 author 2020-02-14 15:44:53
  • reply 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]
    迷心兔 author 2020-02-14 15:51:54
  • reply Well, just solve it. My carriage return and line feed also have no effect.
    查无此人 author 2020-02-14 21:40:55
  • reply In my code, there is a small bug in the add page, [No change: <option value="0">Close</option>] [Changed<option value="2">Close</option>]
    迷心兔 author 2020-02-15 00:48:03
  • reply [No change: option value="0">Close</option】【已改:option value="2">Close</option]
    迷心兔 author 2020-02-15 00:49:17
  • reply The first two replies are incomplete. Sorry, you can check the link: https://blog.csdn.net/mixintu/article/details/104302187
    迷心兔 author 2020-02-15 01:01:36
  • reply OK, modified
    查无此人 author 2020-02-15 14:49:50
  • reply 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
    迷心兔 author 2020-02-15 18:13:40
  • reply I used the built-in paginate function today and it can output data, but the pagination code does not appear in some templates.
    迷心兔 author 2020-03-02 14:39:01
  • reply You asked again, but I didn’t see it. You can add me. Can't reply in time here.
    查无此人 author 2020-03-19 11:40:00
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!