{"id":2499,"date":"2019-03-24T13:19:39","date_gmt":"2019-03-24T05:19:39","guid":{"rendered":"https:\/\/www.baishitou.cn\/?p=2499"},"modified":"2019-03-24T13:19:39","modified_gmt":"2019-03-24T05:19:39","slug":"%e7%bb%87%e6%a2%a6dedecms%e6%a0%b9%e6%8d%ae%e8%87%aa%e5%ae%9a%e4%b9%89%e5%ad%97%e6%ae%b5%e5%a1%ab%e7%9a%84%e6%96%87%e7%ab%a0id%e8%8e%b7%e5%8f%96%e7%9b%b8%e5%85%b3%e6%96%87%e7%ab%a0","status":"publish","type":"post","link":"https:\/\/www.baishitou.cn\/2499.html","title":{"rendered":"\u7ec7\u68a6dedecms\u6839\u636e\u81ea\u5b9a\u4e49\u5b57\u6bb5\u586b\u7684\u6587\u7ae0id\u83b7\u53d6\u76f8\u5173\u6587\u7ae0"},"content":{"rendered":"

1\u3001\u540e\u53f0\u6a21\u578b\u6dfb\u52a0\u81ea\u5b9a\u4e49\u5b57\u6bb5\uff0c\u6570\u636e\u7c7b\u578b\u7528\u5355\u884c\u6587\u672c(varchar)\uff0c\u7528\u6765\u586b\u8981\u8c03\u7528\u7684\u76f8\u5173\u6587\u7ae0\u7684id,\u586b\u591a\u4e2a\u6587\u7ae0id\u7528\u82f1\u6587\u9017\u53f7\u9694\u5f00\uff0c\u4f8b\u5982\uff1a3,5,6,8,9<\/p>\n

2\u3001\u5728\u5185\u5bb9\u9875\u6a21\u677f\u91cc\u5199dede:sql\u6807\u7b7e<\/p>\n

{dede:sql sql=\"SELECT * FROM #@__archives WHERE arcrank>-1 AND id in(~\u81ea\u5b9a\u4e49\u5b57\u6bb5\u540d~) ORDER BY FIELD(id,~\u81ea\u5b9a\u4e49\u5b57\u6bb5\u540d~)\"}\r\n<a href=\"[field:id runphp=yes]$id=@me;$url=GetOneArchive($id);@me=$url['arcurl'];[\/field:id]\"><img src=\"[field:litpic\/]\">[field:title\/]<\/a>\r\n<p>[field:description\/]<\/p>\r\n{\/dede:sql}<\/code><\/pre>\n

3\u3001\u6253\u5f00 \/include\/taglib\/sql.lib.php \u627e\u5230<\/p>\n

preg_match_all(\"\/~([A-Za-z0-9]+)~\/s\", $sql, $conditions);<\/code><\/pre>\n

\u6539\u6210<\/p>\n

preg_match_all(\"\/~([A-Za-z0-9_]+)~\/s\", $sql, $conditions);<\/code><\/pre>\n

\u7ee7\u7eed\u627e\u5230<\/p>\n

$sql = str_replace($conditions[0][$key], \"'\".addslashes($refObj->Fields[$value]).\"'\", $sql);<\/code><\/pre>\n

\u6539\u6210<\/p>\n

if(is_numeric(str_replace(',','',$refObj->Fields[$value])))\r\n{\r\n\t$sql = str_replace($conditions[0][$key], addslashes($refObj->Fields[$value]), $sql);\r\n}\r\nelse\r\n{\r\n\t$sql = str_replace($conditions[0][$key], \"'\".addslashes($refObj->Fields[$value]).\"'\", $sql);\r\n}<\/code><\/pre>\n

\u5b8c\u6210<\/p>\n","protected":false},"excerpt":{"rendered":"

1\u3001\u540e\u53f0\u6a21\u578b\u6dfb\u52a0\u81ea\u5b9a\u4e49\u5b57\u6bb5\uff0c\u6570\u636e\u7c7b\u578b\u7528\u5355\u884c\u6587\u672c(varchar)\uff0c\u7528\u6765\u586b\u8981\u8c03\u7528\u7684\u76f8\u5173\u6587\u7ae0\u7684id,\u586b\u591a\u4e2a\u6587\u7ae0id […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[834,731,149,833],"class_list":["post-2499","post","type-post","status-publish","format-standard","hentry","category-web","tag-dedesql","tag-731","tag-149","tag-833"],"_links":{"self":[{"href":"https:\/\/www.baishitou.cn\/wp-json\/wp\/v2\/posts\/2499","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.baishitou.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.baishitou.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.baishitou.cn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.baishitou.cn\/wp-json\/wp\/v2\/comments?post=2499"}],"version-history":[{"count":0,"href":"https:\/\/www.baishitou.cn\/wp-json\/wp\/v2\/posts\/2499\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.baishitou.cn\/wp-json\/wp\/v2\/media?parent=2499"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.baishitou.cn\/wp-json\/wp\/v2\/categories?post=2499"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.baishitou.cn\/wp-json\/wp\/v2\/tags?post=2499"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}