mo-xing.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. <!DOCTYPE HTML>
  2. <html lang="" >
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  6. <title>模型 · GitBook</title>
  7. <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  8. <meta name="description" content="">
  9. <meta name="generator" content="GitBook 3.2.3">
  10. <link rel="stylesheet" href="../gitbook/style.css">
  11. <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
  12. <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
  13. <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
  14. <meta name="HandheldFriendly" content="true"/>
  15. <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
  16. <meta name="apple-mobile-web-app-capable" content="yes">
  17. <meta name="apple-mobile-web-app-status-bar-style" content="black">
  18. <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
  19. <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
  20. <link rel="next" href="shi-tu.html" />
  21. <link rel="prev" href="kong-zhi-qi.html" />
  22. </head>
  23. <body>
  24. <div class="book">
  25. <div class="book-summary">
  26. <div id="book-search-input" role="search">
  27. <input type="text" placeholder="Type to search" />
  28. </div>
  29. <nav role="navigation">
  30. <ul class="summary">
  31. <li class="chapter " data-level="1.1" data-path="../">
  32. <a href="../">
  33. 简介
  34. </a>
  35. </li>
  36. <li class="chapter " data-level="1.2" data-path="../chapter1.html">
  37. <a href="../chapter1.html">
  38. 基础用法
  39. </a>
  40. <ul class="articles">
  41. <li class="chapter " data-level="1.2.1" data-path="pei-zhi.html">
  42. <a href="pei-zhi.html">
  43. 配置
  44. </a>
  45. </li>
  46. <li class="chapter " data-level="1.2.2" data-path="lu-you.html">
  47. <a href="lu-you.html">
  48. 路由
  49. </a>
  50. </li>
  51. <li class="chapter " data-level="1.2.3" data-path="kong-zhi-qi.html">
  52. <a href="kong-zhi-qi.html">
  53. 控制器
  54. </a>
  55. </li>
  56. <li class="chapter active" data-level="1.2.4" data-path="mo-xing.html">
  57. <a href="mo-xing.html">
  58. 模型
  59. </a>
  60. </li>
  61. <li class="chapter " data-level="1.2.5" data-path="shi-tu.html">
  62. <a href="shi-tu.html">
  63. 视图
  64. </a>
  65. </li>
  66. </ul>
  67. </li>
  68. <li class="chapter " data-level="1.3" data-path="../qi-ta-bu-chong.html">
  69. <a href="../qi-ta-bu-chong.html">
  70. 其他补充
  71. </a>
  72. <ul class="articles">
  73. <li class="chapter " data-level="1.3.1" data-path="../qi-ta-bu-chong/param.html">
  74. <a href="../qi-ta-bu-chong/param.html">
  75. Param
  76. </a>
  77. </li>
  78. <li class="chapter " data-level="1.3.2" data-path="../qi-ta-bu-chong/tablehelper.html">
  79. <a href="../qi-ta-bu-chong/tablehelper.html">
  80. TableHelper
  81. </a>
  82. </li>
  83. <li class="chapter " data-level="1.3.3" data-path="../qi-ta-bu-chong/ke-zhi-xing-jiao-ben.html">
  84. <a href="../qi-ta-bu-chong/ke-zhi-xing-jiao-ben.html">
  85. 可执行脚本
  86. </a>
  87. </li>
  88. </ul>
  89. </li>
  90. <li class="divider"></li>
  91. <li>
  92. <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
  93. Published with GitBook
  94. </a>
  95. </li>
  96. </ul>
  97. </nav>
  98. </div>
  99. <div class="book-body">
  100. <div class="body-inner">
  101. <div class="book-header" role="navigation">
  102. <!-- Title -->
  103. <h1>
  104. <i class="fa fa-circle-o-notch fa-spin"></i>
  105. <a href=".." >模型</a>
  106. </h1>
  107. </div>
  108. <div class="page-wrapper" tabindex="-1" role="main">
  109. <div class="page-inner">
  110. <div id="book-search-results">
  111. <div class="search-noresults">
  112. <section class="normal markdown-section">
  113. <h3 id="&#x6A21;&#x578B;">&#x6A21;&#x578B;</h3>
  114. <h6 id="&#x547D;&#x540D;&#x7EA6;&#x5B9A;">&#x547D;&#x540D;&#x7EA6;&#x5B9A;</h6>
  115. <p>&#x7C7B;&#x540D;&#x4F7F;&#x7528;UpperCamelCase&#x98CE;&#x683C;&#xFF0C;&#x6587;&#x4EF6;&#x540D;&#x548C;&#x7C7B;&#x540D;&#x4FDD;&#x6301;&#x4E00;&#x81F4;&#x3002;</p>
  116. <h6 id="&#x7F16;&#x5199;&#x683C;&#x5F0F;">&#x7F16;&#x5199;&#x683C;&#x5F0F;</h6>
  117. <p><code>Model</code>&#x4E3A;&#x65E0;&#x7F13;&#x5B58;&#x64CD;&#x4F5C;,<code>R2MModel</code>&#x5E26;&#x7F13;&#x5B58;&#x64CD;&#x4F5C;&#x3002;</p>
  118. <p><code>R2MModel</code>&#x7EE7;&#x627F;&#x4E8E;<code>Model</code>&#x90FD;&#x662F;&#x4F7F;&#x7528;<a href="../qi-ta-bu-chong/tablehelper.html"><code>TableHelper</code></a>&#x8FDB;&#x884C;&#x6570;&#x636E;&#x5E93;&#x64CD;&#x4F5C;&#xFF0C;&#x7F13;&#x5B58;&#x901A;&#x8FC7;<code>Redis2Mysql</code>&#x4F7F;&#x7ED3;&#x679C;&#x5B58;&#x5165;redis&#x3002;</p>
  119. <p>&#x5FC5;&#x987B;&#x914D;&#x7F6E;<code>$tableName</code> <code>$dbKey</code>&#x5C5E;&#x6027;&#xFF0C;&#x5E26;&#x7F13;&#x5B58;model&#x8FD8;&#x9700;&#x914D;&#x7F6E;<code>$cacheKey</code>&#x3002;</p>
  120. <p>&#x793A;&#x4F8B;&#xFF1A;</p>
  121. <pre><code class="lang-php"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Foo</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">Model</span> </span>{
  122. <span class="hljs-keyword">protected</span> $tableName = <span class="hljs-string">&apos;foo&apos;</span>; <span class="hljs-comment">// &#x8868;&#x540D;</span>
  123. <span class="hljs-keyword">protected</span> $dbKey = <span class="hljs-string">&apos;database_key_config&apos;</span>; <span class="hljs-comment">// &#x540D;&#x5B57;&#x670D;&#x52A1;&#x6570;&#x636E;&#x5E93;&#x914D;&#x7F6E;</span>
  124. <span class="hljs-keyword">public</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">getFoo</span><span class="hljs-params">($id)</span> </span>{
  125. <span class="hljs-keyword">return</span> $this-&gt;objTable-&gt;getRow([<span class="hljs-string">&apos;id&apos;</span> =&gt; $id]);
  126. }
  127. }
  128. <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Bar</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">R2MModel</span> </span>{
  129. <span class="hljs-keyword">protected</span> $tableName = <span class="hljs-string">&apos;bar&apos;</span>; <span class="hljs-comment">// &#x8868;&#x540D;</span>
  130. <span class="hljs-keyword">protected</span> $dbKey = <span class="hljs-string">&apos;database_key_config&apos;</span>; <span class="hljs-comment">// &#x540D;&#x5B57;&#x670D;&#x52A1;&#x6570;&#x636E;&#x5E93;&#x914D;&#x7F6E;</span>
  131. <span class="hljs-keyword">protected</span> $cacheKey = <span class="hljs-string">&apos;redis_key_config&apos;</span>; <span class="hljs-comment">// &#x540D;&#x5B57;&#x670D;&#x52A1;redis&#x914D;&#x7F6E;</span>
  132. <span class="hljs-keyword">public</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">getBar</span><span class="hljs-params">($id)</span> </span>{
  133. <span class="hljs-keyword">return</span> $this-&gt;objR2m-&gt;getRow([<span class="hljs-string">&apos;id&apos;</span> =&gt; $id]);
  134. }
  135. }
  136. </code></pre>
  137. </section>
  138. </div>
  139. <div class="search-results">
  140. <div class="has-results">
  141. <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
  142. <ul class="search-results-list"></ul>
  143. </div>
  144. <div class="no-results">
  145. <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
  146. </div>
  147. </div>
  148. </div>
  149. </div>
  150. </div>
  151. </div>
  152. <a href="kong-zhi-qi.html" class="navigation navigation-prev " aria-label="Previous page: 控制器">
  153. <i class="fa fa-angle-left"></i>
  154. </a>
  155. <a href="shi-tu.html" class="navigation navigation-next " aria-label="Next page: 视图">
  156. <i class="fa fa-angle-right"></i>
  157. </a>
  158. </div>
  159. <script>
  160. var gitbook = gitbook || [];
  161. gitbook.push(function() {
  162. gitbook.page.hasChanged({"page":{"title":"模型","level":"1.2.4","depth":2,"next":{"title":"视图","level":"1.2.5","depth":2,"path":"chapter1/shi-tu.md","ref":"chapter1/shi-tu.md","articles":[]},"previous":{"title":"控制器","level":"1.2.3","depth":2,"path":"chapter1/kong-zhi-qi.md","ref":"chapter1/kong-zhi-qi.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"chapter1/mo-xing.md","mtime":"2018-09-08T03:26:31.813Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-09-13T03:13:15.790Z"},"basePath":"..","book":{"language":""}});
  163. });
  164. </script>
  165. </div>
  166. <script src="../gitbook/gitbook.js"></script>
  167. <script src="../gitbook/theme.js"></script>
  168. <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
  169. <script src="../gitbook/gitbook-plugin-search/search.js"></script>
  170. <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
  171. <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
  172. <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
  173. <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
  174. </body>
  175. </html>