{"id":49178,"date":"2024-12-02T14:18:47","date_gmt":"2024-12-02T06:18:47","guid":{"rendered":"https:\/\/fwq.ai\/blog\/49178\/"},"modified":"2024-12-02T14:18:47","modified_gmt":"2024-12-02T06:18:47","slug":"thinkphp6-%e4%b8%ad-collection-%e5%af%b9%e8%b1%a1%e7%9a%84-value-%e6%96%b9%e6%b3%95%e6%8a%a5%e9%94%99%ef%bc%9a%e4%b8%ba%e4%bb%80%e4%b9%88%e8%b0%83%e7%94%a8%e6%9c%aa%e5%ae%9a%e4%b9%89%e7%9a%84","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/49178\/","title":{"rendered":"ThinkPHP6 \u4e2d Collection \u5bf9\u8c61\u7684 value() \u65b9\u6cd5\u62a5\u9519\uff1a\u4e3a\u4ec0\u4e48\u8c03\u7528\u672a\u5b9a\u4e49\u7684\u65b9\u6cd5\uff1f"},"content":{"rendered":"<p><b><\/b> <\/p>\n<h1>ThinkPHP6 \u4e2d Collection \u5bf9\u8c61\u7684 value() \u65b9\u6cd5\u62a5\u9519\uff1a\u4e3a\u4ec0\u4e48\u8c03\u7528\u672a\u5b9a\u4e49\u7684\u65b9\u6cd5\uff1f<\/h1>\n<p>\u5077\u5077\u52aa\u529b\uff0c\u6084\u65e0\u58f0\u606f\u5730\u53d8\u5f3a\uff0c\u7136\u540e\u60ca\u8273\u6240\u6709\u4eba\uff01\u54c8\u54c8\uff0c\u5c0f\u4f19\u4f34\u4eec\u53c8\u6765\u5b66\u4e60\u5566~\u4eca\u5929\u6211\u5c06\u7ed9\u5927\u5bb6\u4ecb\u7ecd<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300aThinkPHP6 \u4e2d Collection \u5bf9\u8c61\u7684 value() \u65b9\u6cd5\u62a5\u9519\uff1a\u4e3a\u4ec0\u4e48\u8c03\u7528\u672a\u5b9a\u4e49\u7684\u65b9\u6cd5\uff1f\u300b<\/span>\uff0c\u8fd9\u7bc7\u6587\u7ae0\u4e3b\u8981\u4f1a\u8bb2\u5230<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\u7b49\u7b49\u77e5\u8bc6\u70b9\uff0c\u4e0d\u77e5\u9053\u5927\u5bb6\u5bf9\u5176\u90fd\u6709\u591a\u5c11\u4e86\u89e3\uff0c\u4e0b\u9762\u6211\u4eec\u5c31\u4e00\u8d77\u6765\u770b\u4e00\u5427\uff01\u5f53\u7136\uff0c\u975e\u5e38\u5e0c\u671b\u5927\u5bb6\u80fd\u591a\u591a\u8bc4\u8bba\uff0c\u7ed9\u51fa\u5408\u7406\u7684\u5efa\u8bae\uff0c\u6211\u4eec\u4e00\u8d77\u5b66\u4e60\uff0c\u4e00\u8d77\u8fdb\u6b65\uff01<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241114\/17315892456735f47d85f62.jpg\" class=\"aligncenter\" title=\"ThinkPHP6 \u4e2d Collection \u5bf9\u8c61\u7684 value() \u65b9\u6cd5\u62a5\u9519\uff1a\u4e3a\u4ec0\u4e48\u8c03\u7528\u672a\u5b9a\u4e49\u7684\u65b9\u6cd5\uff1f\u63d2\u56fe\" alt=\"ThinkPHP6 \u4e2d Collection \u5bf9\u8c61\u7684 value() \u65b9\u6cd5\u62a5\u9519\uff1a\u4e3a\u4ec0\u4e48\u8c03\u7528\u672a\u5b9a\u4e49\u7684\u65b9\u6cd5\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>thinkphp6 \u4e2d thinkcollection::value() \u65b9\u6cd5\u62a5\u9519\uff1a\u8c03\u7528\u672a\u5b9a\u4e49\u7684\u65b9\u6cd5<\/strong><\/p>\n<p>\u5728\u4f7f\u7528 thinkphp6 \u65f6\uff0c\u9047\u5230 value() \u65b9\u6cd5\u672a\u5b9a\u4e49\u7684\u62a5\u9519\uff1a<\/p>\n<pre>call to undefined method think\\collection::value()<\/pre>\n<p>\u6b64\u62a5\u9519\u901a\u5e38\u53d1\u751f\u5728\u4ee5\u4e0b\u60c5\u51b5\u4e0b\uff1a<\/p>\n<p>\u5728\u5b98\u65b9\u624b\u518c\u4e2d\uff0cvalue() \u65b9\u6cd5\u7528\u4e8e\u4ece collection \u5bf9\u8c61\u4e2d\u83b7\u53d6\u6307\u5b9a\u5b57\u6bb5\u7684\u503c\uff0c\u4f46\u5b9e\u9645\u4f7f\u7528\u65f6\u5374\u63d0\u793a\u672a\u5b9a\u4e49\u3002<\/p>\n<p>\u539f\u56e0\u5728\u4e8e\uff0c\u5728\u793a\u4f8b\u4ee3\u7801\u4e2d\u591a\u5199\u4e86 select() \u65b9\u6cd5\uff1a<\/p>\n<pre>$result = db::table('admin_info')-&amp;gt;select()-&amp;gt;where('id','2')-&amp;gt;value('name');<\/pre>\n<p>\u6b63\u786e\u7684\u5199\u6cd5\u5e94\u8be5\u662f\uff1a<\/p>\n<pre>$result = Db::table('admin_info')-&amp;gt;where('id','2')-&amp;gt;value('name');<\/pre>\n<p>\u5220\u9664\u591a\u4f59\u7684 select() \u65b9\u6cd5\u540e\uff0c\u5373\u53ef\u89e3\u51b3\u95ee\u9898\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u300aThinkPHP6 \u4e2d Collection \u5bf9\u8c61\u7684 value() \u65b9\u6cd5\u62a5\u9519\uff1a\u4e3a\u4ec0\u4e48\u8c03\u7528\u672a\u5b9a\u4e49\u7684\u65b9\u6cd5\uff1f\u300b\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u5173\u4e8e\u7684\u8d44\u6599\u8bf7\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>ThinkPHP6 \u4e2d Collection \u5bf9\u8c61\u7684 value() \u65b9\u6cd5\u62a5\u9519\uff1a\u4e3a\u4ec0\u4e48\u8c03\u7528\u672a\u5b9a\u4e49\u7684\u65b9\u6cd5\uff1f \u5077\u5077\u52aa\u529b\uff0c\u6084\u65e0\u58f0\u606f\u5730\u53d8\u5f3a\uff0c\u7136\u540e\u60ca\u8273\u6240\u6709\u4eba\uff01\u54c8\u54c8\uff0c\u5c0f\u4f19\u4f34\u4eec\u53c8\u6765\u5b66\u4e60\u5566~\u4eca\u5929\u6211\u5c06\u7ed9\u5927\u5bb6\u4ecb\u7ecd\u300aThinkPHP6 \u4e2d Collection \u5bf9\u8c61\u7684 value() \u65b9\u6cd5\u62a5\u9519\uff1a\u4e3a\u4ec0\u4e48\u8c03\u7528\u672a\u5b9a\u4e49\u7684\u65b9\u6cd5\uff1f\u300b\uff0c\u8fd9\u7bc7\u6587\u7ae0\u4e3b\u8981\u4f1a\u8bb2\u5230\u7b49\u7b49\u77e5\u8bc6\u70b9\uff0c\u4e0d\u77e5\u9053\u5927\u5bb6\u5bf9\u5176\u90fd\u6709\u591a\u5c11\u4e86\u89e3\uff0c\u4e0b\u9762\u6211\u4eec\u5c31\u4e00\u8d77\u6765\u770b\u4e00\u5427\uff01\u5f53\u7136\uff0c\u975e\u5e38\u5e0c\u671b\u5927\u5bb6\u80fd\u591a\u591a\u8bc4\u8bba\uff0c\u7ed9\u51fa\u5408\u7406\u7684\u5efa\u8bae\uff0c\u6211\u4eec\u4e00\u8d77\u5b66\u4e60\uff0c\u4e00\u8d77\u8fdb\u6b65\uff01 thinkphp6 \u4e2d thinkcollection::value() \u65b9\u6cd5\u62a5\u9519\uff1a\u8c03\u7528\u672a\u5b9a\u4e49\u7684\u65b9\u6cd5 \u5728\u4f7f\u7528 thinkphp6 \u65f6\uff0c\u9047\u5230 value() \u65b9\u6cd5\u672a\u5b9a\u4e49\u7684\u62a5\u9519\uff1a call to undefined method think\\collection::value() \u6b64\u62a5\u9519\u901a\u5e38\u53d1\u751f\u5728\u4ee5\u4e0b\u60c5\u51b5\u4e0b\uff1a \u5728\u5b98\u65b9\u624b\u518c\u4e2d\uff0cvalue() \u65b9\u6cd5\u7528\u4e8e\u4ece collection \u5bf9\u8c61\u4e2d\u83b7\u53d6\u6307\u5b9a\u5b57\u6bb5\u7684\u503c\uff0c\u4f46\u5b9e\u9645\u4f7f\u7528\u65f6\u5374\u63d0\u793a\u672a\u5b9a\u4e49\u3002 \u539f\u56e0\u5728\u4e8e\uff0c\u5728\u793a\u4f8b\u4ee3\u7801\u4e2d\u591a\u5199\u4e86 select() \u65b9\u6cd5\uff1a $result = db::table(&#8216;admin_info&#8217;)-&amp;gt;select()-&amp;gt;where(&#8216;id&#8217;,&#8217;2&#8242;)-&amp;gt;value(&#8216;name&#8217;); \u6b63\u786e\u7684\u5199\u6cd5\u5e94\u8be5\u662f\uff1a $result = Db::table(&#8216;admin_info&#8217;)-&amp;gt;where(&#8216;id&#8217;,&#8217;2&#8242;)-&amp;gt;value(&#8216;name&#8217;); \u5220\u9664\u591a\u4f59\u7684 select() \u65b9\u6cd5\u540e\uff0c\u5373\u53ef\u89e3\u51b3\u95ee\u9898\u3002 \u4ee5\u4e0a\u5c31\u662f\u300aThinkPHP6 \u4e2d Collection \u5bf9\u8c61\u7684 value() \u65b9\u6cd5\u62a5\u9519\uff1a\u4e3a\u4ec0\u4e48\u8c03\u7528\u672a\u5b9a\u4e49\u7684\u65b9\u6cd5\uff1f\u300b\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u5173\u4e8e\u7684\u8d44\u6599\u8bf7\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff01<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-49178","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/49178","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=49178"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/49178\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=49178"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=49178"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=49178"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}