├── .gitignore ├── 1.html ├── 10.html ├── 11.html ├── 12.html ├── 13.html ├── 14.html ├── 15.html ├── 2.html ├── 3.html ├── 4.html ├── 5.html ├── 6.html ├── 7.html ├── 8.html ├── 9.html ├── CodeIgniter.chm ├── CodeIgniter.hhc ├── CodeIgniter.hhk ├── CodeIgniter.hhp ├── LICENSE ├── README.md ├── _docs ├── 1.doc ├── 1.txt ├── 10.doc ├── 10.txt ├── 11.doc ├── 11.txt ├── 12.doc ├── 12.now.txt ├── 12.txt ├── 13.txt ├── 14.doc ├── 14.txt ├── 15.txt ├── 2.doc ├── 2.txt ├── 3.doc ├── 3.txt ├── 3_old.doc ├── 4.doc ├── 4.txt ├── 4_old.doc ├── 5.doc ├── 5.txt ├── 6.doc ├── 6.txt ├── 7.doc ├── 7.txt ├── 8.doc ├── 8.txt ├── 9.doc ├── 9.txt ├── CodeIgniter.pdf ├── codeigniter.txt ├── index.txt └── preface.txt ├── _images_source ├── 13.5.1.1_1.png ├── 13.5.1.2_1.png ├── 3.2-1.png ├── 3.8.4-1.png ├── CodeIgniter-01.jpg ├── CodeIgniter-02.jpg ├── CodeIgniter-03.png ├── CodeIgniter-04.png ├── CodeIgniter-05.png ├── CodeIgniter-06.png ├── CodeIgniter-07.png ├── CodeIgniter-08.png ├── CodeIgniter-09.png ├── CodeIgniter-10.png ├── CodeIgniter-11.png ├── CodeIgniter-12.png ├── CodeIgniter-13.png ├── CodeIgniter-14.png ├── CodeIgniter-15.png ├── CodeIgniter-16.png ├── CodeIgniter-17.png ├── CodeIgniter-18.png ├── CodeIgniter-19.png ├── CodeIgniter-20.png ├── CodeIgniter-21.jpg ├── CodeIgniter-22.jpg ├── CodeIgniter-23.jpg ├── CodeIgniter-24.png ├── CodeIgniter-25.png ├── CodeIgniter-26.png ├── CodeIgniter-27.png ├── CodeIgniter-28.png ├── CodeIgniter-29.png ├── CodeIgniter-30.png ├── CodeIgniter-31.png ├── CodeIgniter-32.png ├── CodeIgniter-33.png ├── CodeIgniter-34.png ├── CodeIgniter-35.png ├── CodeIgniter-36.png ├── CodeIgniter-37.png ├── CodeIgniter-38.png ├── CodeIgniter-39.png ├── CodeIgniter-40.png ├── CodeIgniter_cover.png └── header.png ├── _other ├── template.html ├── 代码勘误.txt ├── 数据勘误.txt └── 校对记录.txt ├── about_the_author.html ├── about_the_reviewers.html ├── build.bat ├── code ├── Chapter 11 │ └── Do Upload.php ├── Chapter 12 │ └── Function Report me.txt ├── Chapter 13 │ ├── Controller_for_sites_table.php │ ├── delete_function.txt │ ├── insert2_function.txt │ ├── insert_function.txt │ ├── showall_function.txt │ ├── test_function.txt │ └── trydelete_function.txt ├── Chapter 14 │ └── Function to run an individual test.txt ├── Chapter 4 │ └── Query to set up 'websites' database.sql └── Chapter 5 │ └── My Display Model.php ├── credits.html ├── credits_cn.html ├── css └── main.css ├── images ├── 13.5.1.1_1.gif ├── 13.5.1.2_1.gif ├── 3.2_1.jpg ├── 3.8.4_1.gif ├── 7.1.1_1.gif ├── 7.1.1_2.gif ├── 7.1.1_3.gif ├── 7.1.1_4.gif ├── 7.2_1.gif ├── CodeIgniter-03.png ├── CodeIgniter-05.png ├── CodeIgniter-06.png ├── CodeIgniter-08.gif ├── CodeIgniter-09.gif ├── CodeIgniter-10.gif ├── CodeIgniter-11.gif ├── CodeIgniter-12.gif ├── CodeIgniter-13.gif ├── CodeIgniter-14.gif ├── CodeIgniter-15.gif ├── CodeIgniter-16.gif ├── CodeIgniter-17.gif ├── CodeIgniter-18.gif ├── CodeIgniter-19.gif ├── CodeIgniter-20.gif ├── CodeIgniter-21.jpg ├── CodeIgniter-22.jpg ├── CodeIgniter-23.jpg ├── CodeIgniter-24.gif ├── CodeIgniter-25.gif ├── CodeIgniter-26.gif ├── CodeIgniter-27.gif ├── CodeIgniter-28.gif ├── CodeIgniter-29.gif ├── CodeIgniter-30.gif ├── CodeIgniter-31.gif ├── CodeIgniter-32.gif ├── CodeIgniter-33.gif ├── CodeIgniter-34.gif ├── CodeIgniter-35.jpg ├── CodeIgniter-36.gif ├── CodeIgniter-37.jpg ├── CodeIgniter-38.gif ├── CodeIgniter-39.gif ├── CodeIgniter-40.gif ├── CodeIgniter_02.jpg ├── CodeIgniter_07.jpg ├── CodeIgniter_cover.png ├── copycode.gif └── header.png ├── index.html ├── js ├── _main.js └── main.js ├── preface.html ├── preface_cn.html └── table_of_contents.html /.gitignore: -------------------------------------------------------------------------------- 1 | _errorlog.txt 2 | 3 | ################# 4 | ## Eclipse 5 | ################# 6 | 7 | *.pydevproject 8 | .project 9 | .metadata 10 | bin/ 11 | tmp/ 12 | *.tmp 13 | *.bak 14 | *.swp 15 | *~.nib 16 | local.properties 17 | .classpath 18 | .settings/ 19 | .loadpath 20 | 21 | # External tool builders 22 | .externalToolBuilders/ 23 | 24 | # Locally stored "Eclipse launch configurations" 25 | *.launch 26 | 27 | # CDT-specific 28 | .cproject 29 | 30 | # PDT-specific 31 | .buildpath 32 | 33 | 34 | ################# 35 | ## Visual Studio 36 | ################# 37 | 38 | ## Ignore Visual Studio temporary files, build results, and 39 | ## files generated by popular Visual Studio add-ons. 40 | 41 | # User-specific files 42 | *.suo 43 | *.user 44 | *.sln.docstates 45 | 46 | # Build results 47 | 48 | [Dd]ebug/ 49 | [Rr]elease/ 50 | x64/ 51 | build/ 52 | [Bb]in/ 53 | [Oo]bj/ 54 | 55 | # MSTest test Results 56 | [Tt]est[Rr]esult*/ 57 | [Bb]uild[Ll]og.* 58 | 59 | *_i.c 60 | *_p.c 61 | *.ilk 62 | *.meta 63 | *.obj 64 | *.pch 65 | *.pdb 66 | *.pgc 67 | *.pgd 68 | *.rsp 69 | *.sbr 70 | *.tlb 71 | *.tli 72 | *.tlh 73 | *.tmp 74 | *.tmp_proj 75 | *.log 76 | *.vspscc 77 | *.vssscc 78 | .builds 79 | *.pidb 80 | *.log 81 | *.scc 82 | 83 | # Visual C++ cache files 84 | ipch/ 85 | *.aps 86 | *.ncb 87 | *.opensdf 88 | *.sdf 89 | *.cachefile 90 | 91 | # Visual Studio profiler 92 | *.psess 93 | *.vsp 94 | *.vspx 95 | 96 | # Guidance Automation Toolkit 97 | *.gpState 98 | 99 | # ReSharper is a .NET coding add-in 100 | _ReSharper*/ 101 | *.[Rr]e[Ss]harper 102 | 103 | # TeamCity is a build add-in 104 | _TeamCity* 105 | 106 | # DotCover is a Code Coverage Tool 107 | *.dotCover 108 | 109 | # NCrunch 110 | *.ncrunch* 111 | .*crunch*.local.xml 112 | 113 | # Installshield output folder 114 | [Ee]xpress/ 115 | 116 | # DocProject is a documentation generator add-in 117 | DocProject/buildhelp/ 118 | DocProject/Help/*.HxT 119 | DocProject/Help/*.HxC 120 | DocProject/Help/*.hhc 121 | DocProject/Help/*.hhk 122 | DocProject/Help/*.hhp 123 | DocProject/Help/Html2 124 | DocProject/Help/html 125 | 126 | # Click-Once directory 127 | publish/ 128 | 129 | # Publish Web Output 130 | *.Publish.xml 131 | *.pubxml 132 | 133 | # NuGet Packages Directory 134 | ## TODO: If you have NuGet Package Restore enabled, uncomment the next line 135 | #packages/ 136 | 137 | # Windows Azure Build Output 138 | csx 139 | *.build.csdef 140 | 141 | # Windows Store app package directory 142 | AppPackages/ 143 | 144 | # Others 145 | sql/ 146 | *.Cache 147 | ClientBin/ 148 | [Ss]tyle[Cc]op.* 149 | ~$* 150 | *~ 151 | *.dbmdl 152 | *.[Pp]ublish.xml 153 | *.pfx 154 | *.publishsettings 155 | 156 | # RIA/Silverlight projects 157 | Generated_Code/ 158 | 159 | # Backup & report files from converting an old project file to a newer 160 | # Visual Studio version. Backup files are not needed, because we have git ;-) 161 | _UpgradeReport_Files/ 162 | Backup*/ 163 | UpgradeLog*.XML 164 | UpgradeLog*.htm 165 | 166 | # SQL Server files 167 | App_Data/*.mdf 168 | App_Data/*.ldf 169 | 170 | ############# 171 | ## Windows detritus 172 | ############# 173 | 174 | # Windows image file caches 175 | Thumbs.db 176 | ehthumbs.db 177 | 178 | # Folder config file 179 | Desktop.ini 180 | 181 | # Recycle Bin used on file shares 182 | $RECYCLE.BIN/ 183 | 184 | # Mac crap 185 | .DS_Store 186 | 187 | 188 | ############# 189 | ## Python 190 | ############# 191 | 192 | *.py[co] 193 | 194 | # Packages 195 | *.egg 196 | *.egg-info 197 | dist/ 198 | build/ 199 | eggs/ 200 | parts/ 201 | var/ 202 | sdist/ 203 | develop-eggs/ 204 | .installed.cfg 205 | 206 | # Installer logs 207 | pip-log.txt 208 | 209 | # Unit test / coverage reports 210 | .coverage 211 | .tox 212 | 213 | #Translations 214 | *.mo 215 | 216 | #Mr Developer 217 | .mr.developer.cfg 218 | -------------------------------------------------------------------------------- /1.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/1.html -------------------------------------------------------------------------------- /10.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/10.html -------------------------------------------------------------------------------- /11.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/11.html -------------------------------------------------------------------------------- /12.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/12.html -------------------------------------------------------------------------------- /13.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/13.html -------------------------------------------------------------------------------- /14.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/14.html -------------------------------------------------------------------------------- /15.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/15.html -------------------------------------------------------------------------------- /2.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/2.html -------------------------------------------------------------------------------- /3.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/3.html -------------------------------------------------------------------------------- /4.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/4.html -------------------------------------------------------------------------------- /5.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/5.html -------------------------------------------------------------------------------- /6.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/6.html -------------------------------------------------------------------------------- /7.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/7.html -------------------------------------------------------------------------------- /8.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/8.html -------------------------------------------------------------------------------- /9.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/9.html -------------------------------------------------------------------------------- /CodeIgniter.chm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/CodeIgniter.chm -------------------------------------------------------------------------------- /CodeIgniter.hhc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/CodeIgniter.hhc -------------------------------------------------------------------------------- /CodeIgniter.hhk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/CodeIgniter.hhk -------------------------------------------------------------------------------- /CodeIgniter.hhp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/CodeIgniter.hhp -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | 203 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 《CodeIgniter for Rapid PHP Application Development》中文翻译项目 2 | ================================= 3 | 4 | 简介 5 | --------------------------------- 6 | **中文名**:《PHP 框架 CodeIgniter 3 - 快速 Web 应用开发详解》 7 | 8 | ![image](images/CodeIgniter_cover.png) 9 | 10 | 我们要特别感谢 [李嵩波](http://weibo.com/songboli)(原新浪CTO) 先生在百忙之中为本书作序,也要感谢 PHPChina 社区的 chenz1117 对于翻译工作所作出的巨大贡献,还包括 [沧蓝](http://fredwu.me/) 等朋友对翻译技术上的问题所给予的巨大帮助,还包括许多为本书做过贡献的朋友,在这里就不一一列举了,书中有详细的制作者名单,让我们再次对他们表示衷心的感谢! 11 | 12 | 本书是第一本详细介绍 CodeIgniter 框架的著作(目前已经有了另外几本介绍 CI 的著作了),下面是本书的一个简短介绍: 13 | 14 | > 本书详细讲解了 CI 的一些主要特性。本书并不包含 CI 的所有内容和全部细节。CI 有一本出色的在线《用户指南》,它详细讲解了大多数的内容。它可以与 CI 一起下载。 15 | 16 | > 本书并不想重复《用户指南》中的内容。相反,本书试图让你轻松了解 CI 框架是如何工作的,那么,你可以先决定它是否对你有价值,然后再阅读本书。 17 | 18 | > 在试图解释 CI 是如何工作时,本书的某些内容已经超出了《用户指南》的范围。(《用户指南》更注重实际应用。)这意味着在“实战训练”中有一些非常理论化的章节。我发现这有助于理解 CI 内部的运行机制;否则,当你遇到令人费解的错误消息时就不容易解决。 19 | 20 | > 我尝试在展示 CI 代码段时使用一个“真实世界”的例子。我想展示的是,CI 可以用于开发一个正式的网站。目前,我手头上有几个正在运行的客户网站,我希望依照我指定的方式去对其进行检测控制以及测试,同时记录下程序操作行为,在我需要时我可以得到一份相关的报告。 21 | 22 | > 本书中的范例无法将 CI 的功能一丝不漏的完全展示,但我想这些范例应当还是在一定程度上展现了 CI 在简化处理常用应用(以及一些非常用应用)上的能力。 23 | 24 | > 本书系统地讲解了 CodeIgniter 的主要特性,并配合相应的代码范例进行了详尽的解释,使你能够由浅入深地掌握 CodeIgniter。 25 | 26 | 最后,感谢社区所有朋友的大力支持与关心! 27 | 28 | 相关链接: http://codeigniter.org.cn/forums/thread-1464-1-1.html 29 | 30 | 编译方法 31 | --------------------------------- 32 | 目前只支持 Windows 平台的编译。 33 | 34 | 需要用到的工具: 35 | * HTML Help Workshop 下载: http://www.microsoft.com/en-us/download/details.aspx?id=21138 36 | 37 | 把 hhc.exe 加入到 PATH 环境变量中,然后执行 build.bat,即可生成 CodeIgniter.chm 文件。 38 | -------------------------------------------------------------------------------- /_docs/1.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_docs/1.doc -------------------------------------------------------------------------------- /_docs/1.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_docs/1.txt -------------------------------------------------------------------------------- /_docs/10.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_docs/10.doc -------------------------------------------------------------------------------- /_docs/10.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_docs/10.txt -------------------------------------------------------------------------------- /_docs/11.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_docs/11.doc -------------------------------------------------------------------------------- /_docs/11.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_docs/11.txt -------------------------------------------------------------------------------- /_docs/12.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_docs/12.doc -------------------------------------------------------------------------------- /_docs/12.now.txt: -------------------------------------------------------------------------------- 1 | > Production Versions,Updates, and Big Decisions 2 | > 第 12 章 产品版本,升级和重大决定 3 | 第12章 产品版本、升级和重大决定 4 | 5 | > The great day has come. Your development site is running well enough on your local development for you to transfer it to a production site hosted on a remote web server. It should be easy to do this. Copy over all the files, including the whole of the system folder, update the config settings, copy over and link to the database, and away you go. Sometimes, it really is that easy. 6 | > 有意义的一天来临了。你开发的网站在你的本地开发环境中运行得足够好了,是时候把它上传到远程的WEB服务器上成为一个正式运行的网站了。实现它应该是容易的。上传所有的文件,包括系统文件夹的全部, 更新 config 设置, 复制完毕并连接到数据库, 把它们传送出去。 有时候,它真的是很容易。 7 | 伟大的一天终于到来了!你的网站在本地环境中已经运行得足够好,是时候把它上传到远程服务器上使之成为一个正式运行的网站了。这件事按说很容易:上传所有的文件,包括系统文件夹的全部、更新config设置,复制完成后连接到数据库,以及其他。有时候,这的确很容易。 8 | 9 | > But when it isn't, it's always the night before you are giving an all-important presentation to a venture capitalist or a major prospect. So, in case this happens to you, this chapter covers: 10 | > 但是当它还没有成功的时候,它处在你把重要的一切呈现在一个风险资本家或公众视野面前的前夜。 因此, 为了防止出现意外, 这一章涉及: 11 | 在你把重要的一切呈现在风投或公众视野的前夜,也就是在还没完成时。此时,为了防止出现意外,这一章将告诉你: 12 | 13 | > ·What to look for in your config files 14 | > 该在你的 config 文件中设置什么 15 | 你该在config文件中设置什么 16 | 17 | > ·Some diagnostic tools to use if you get stuck 18 | > 如果出现问题需要的一些诊断工具 19 | 出现问题需要的一些诊断工具 20 | 21 | > ·Some potential differences between servers that may trip you up 22 | > 本地服务器与可能让你出现差错的服务器上的隐性差异 23 | 可能出现问题的服务器与本地服务器的隐性差异 24 | 25 | > ·Some notes on security, now that you're out there in the big world 26 | > 几点安全提示, 现在你将处身于大千世界 27 | 几点安全提示, 你将身处于大千世界 28 | 29 | > Next, this chapter covers upgrading, and looks at some of the ways in which CI has changed in the year it's been available. How stable is it? What decisions should you make if you are committing a critical site to it? And what should you do, once your site is up and running, if Rick Ellis brings out a newer version of CI? 30 | > 下一步, 这一章包括升级, 以及留意那些CI在年内已经改变的一些方式。它稳定吗? 如果你提交一个重要网站你应该如何决策?你该怎么行动?一旦你的网站开始运作,而CI又推出新版本你又如何应对? 31 | 然后,这一章还包括了升级以及CI在最近几年的一些更新。它稳定吗? 当要提交一个重要网站时你该如何选择?你该如何操作?一旦你的网站开始运作,而CI推出了新版本你又该如何应对? 32 | 33 | > Lastly, we briefly discuss making your own alterations to the core of CI. It's all there; it's open-source it's possible. Whether it's sensible or not is another matter. 34 | > 最后,我们简短地讨论如何针对 CI 的核心作出你自己的修改。它都在那里; 它是开放源代码的,修改是可能的。 是否可行是另一件事情。 35 | 最后,我们简短地讨论如何针对CI的核心做你的自定义修改。它就在那里,它是开放源代码的,是可以修改的——但是否可行是另一码事。 36 | 37 | > Connections: Check the Config Files 38 | > 连接: 检查 Config 文件 39 | 连接:检查Config文件 40 | 41 | > Systems usually fail at the interfaces. That's what your config files are there for: to give you a place to put all those interfaces. If you haven't done so, you've missed one of CI's major strengths. 42 | > 系统通常会在接口处出错。 那是为什么需要 config 文件的原因: 给你一个地方放那些接口。 如果你还没有这么做,你已经错过 CI 的主要优点之一。 43 | 系统错误通常是在接口上的。这就是为什么需要config文件:给你一个地方放那些接口。如果你还没这么做,你已经错过CI最主要的优点之一。 44 | 45 | > The major interface problems are likely to be: 46 | > 主要的接口问题可能是: 47 | 主要的接口问题可能是: 48 | 49 | > URLs 50 | > URL 51 | URL 52 | 53 | > CI works by finding files. Your user connects to index.php, and then a whole process of loading starts. At least, it should do. Make sure you have set the web address and server addresses correctly in your config files. The web address is your web root folder; you may have to ask your ISP for the server address, though usually it is clear from their own 'file manager' programme. 54 | > CI 通过查找文件工作。 你的用户连接到 index.php, 然后开始运行整个程序。 至少,它应该运行。 确定你在你的 config文件中已经正确地设置好WEB地址和其它服务器地址。 WEB地址是你的网站根目录;你可能需要咨询你的ISP以便得到服务器地址,他们有他们自己的文件管理系统,一查便知。 55 | CI通过查找文件进行工作。当用户连接到index.php,然后开始运行整个程序。至少,它应该运行。确定你在config文件中已经正确地设置好Web地址和其它服务器地址。Web地址是你的网站根目录。而服务器地址则可能要去问你的ISP,通常在他们提供的“文件管理”菜单中也有。 56 | 57 | > I've had particular issues trying to run sub-domains. Many hosts allow them, but map the domains to folders in ways you don't expect. 58 | > 我曾经尝试运行子域。 许多主机允许这么做, 但是把域映射到你的目录也许不是你希望的。 59 | 我尝试设置子域时曾经遇到过一些特殊的问题。虽然许多主机允许这么做, 但将域直接映射到目录也许并不是你所希望看到的。 60 | 61 | > Databases 62 | > 数据库 63 | 数据库 64 | 65 | > Locating and connecting to your database is often a major issue. Look at your config file and your config/database file. You need to make sure that you have the correct site and server addresses, and the correct database name, address, user name, and password. Be careful with prefixes—sometimes these are added automatically. (Your site is called 'fred'. Your database, you think, is called 'mydata' and your user name is 'mylogin'. But the server thinks they are called 'fred_mydata', 'fred_mylogin', etc.) 66 | > 定位并连接到你的数据库经常是一个主要的话题。 查看你的 config 文件和你的 config/database文件。你需要确定你有正确的网站和服务器地址和正确的数据库名称、地址, 用户名和密码。小心前缀-有时这些自动地被添加的。 (你的网站叫 'fred'。 你的数据库, 叫做 'mydata' 和你的用户名是 'mylogin'. 但是在服务器上他们叫做 'fred_mydata' ,'fred_mylogin', 等等。) 67 | 设置并连接到数据库是一个主要议题。查看你的config文件与config/database文件。你需要确定有正确的网站地址与服务器地址,正确的数据库名、地址、用户名与密码。小心前缀——它有时会自动添加的,比如你的网站叫“fred”,你的数据库名为“mydata”,而你的用户名是“mylogin”,但是在服务器上它们会叫做“fred_mydata”、“fred_mylogin”等等。 68 | 69 | > Sometimes, it helps to create a new user on your database, even if you have one already, and set the log-in for this user's name and password. I have no idea why this works, but it does. 70 | > 有时,它帮助在你的数据库上创建一个新的用户,即使你已经有了一个, 而且设定为以新的用户名和密码登录。 我不知道为什么会这样,但是经常会这样。 71 | 有时,它会在数据库中创建一个新的用户,并设定了登录用的用户名和密码,即使你已经有一个了。我也不知道为什么,但就是会这样。 72 | 73 | > In the config file, you can set CI to accept different types of URI protocols, which determine how the server handles the URI string. The default is: 74 | > 在 config 文件中,你能设定 CI 接受不同的URL协议类型,决定服务器如何处理 URI 字符串。 默认值是: 75 | 在config文件中,你可以设定CI接受不同的URL协议类型,以决定服务器如何处理URI字符串。默认值是: 76 | 77 | > $config['uri_protocol']="auto"; 78 | 79 | 80 | > but there are four other options that you can try if this doesn't work. If the correct option isn't set, you may find your site partly works, but (for example) forms don't call the target page. 81 | > 但是如果这不能正常工作,有其他四个选项可以尝试。 如果正确的选项没被设定,你可能发现你的网站只有部分工作正常(举例来说) 表单不能调用目标页。 82 | 如果它不能正常工作,还有其他四个选项可以试试看。如果没有选择合适选项的话,你可能会发现你的网站不能完全正常的运作,(例如)表单不能调用目标页。 83 | 84 | > Other config Files 85 | > 其他的 config 文件 86 | 其他config文件 87 | 88 | > The config/routes file sets the default path the application follows, if the user doesn't specify a controller�method through the URL (i.e. if they just log on to www.mysite.com). This should normally be set at the default: 89 | > config/routes文件设定程序执行的默认路径,如果用户没有指定一个controller/method (也就是如果他们仅仅登录到www.mysite.com). 这通常应该在默认值中被设定: 90 | 如果用户没有指定明确的controller/method(比如他们仅仅登录到www.mysite.com),config/routes文件则会设定程序执行的默认路径。其默认值可能是: 91 | 92 | > $route['default_controller']='index'; 93 | 94 | 95 | > If you renamed the system folder, then remember that you also need to alter the index.php file in the site's root directory. The default setting is: 96 | > 如果你重新命名系统文件夹了,必须记得你还需要在网站的根目录中改变 index.php 文件。 默认值设定为: 97 | 如果你重新命名过系统文件夹,就必须记得你还需要在网站的根目录中修改index.php文件。该值默认为: 98 | 99 | > $system_folder="system"; 100 | 101 | 102 | > Look Out for PHP 4/5 and Operating System Differences 103 | > 找出PHP 4/5 和操作系统间的差异 104 | 找到PHP 4/5和操作系统间的差异 105 | 106 | > CI should be able to live with any version of PHP including and later than 4.3. However, this doesn't mean that any PHP code you write will also be compatible—so if you wrote it on Xampplite using PHP 5, and are moving to an ISP with a PHP 4 server, look out for problems due to language differences. 107 | > CI 应该能够兼容PHP 4.3及以后的任何版本. 然而,这不意味着你写的任何的 PHP 编码都能正常工作-因此如果你在使用 PHP 5, 并且正在向一个 PHP 4 服务器迁移, 由于版本不同有可能引发问题。 108 | CI应该能够兼容PHP 4.3及更高版本。但这不意味着你写的任何的PHP程序都能正常工作——如果你在使用PHP 5,但正在向一个PHP 4服务器迁移时,就可能会遇到由于版本不同引发的问题。 109 | 110 | > PHP (of whatever version) can be set up in different ways. It's worth running phpinfo() on your local and remote sites, and checking for differences. 111 | > PHP(无论哪一个版本) 可能以不同的方式被建立。值得一做的是在你本地和远程服务器上运行phpinfo(), 找到它们之间的差异。 112 | (无论哪一个版本的)PHP环境都可以不同的方式搭建。值得一做的是在你本地和远程服务器上都运行phpinfo(),以找到它们的差异。 113 | 114 | > Case sensitivity is different between Microsoft and Linux servers. So if you've developed your site on a PC, and then uploaded it to a Linux-based server, expect the server to report that it can't find some of the models or libraries you want to load. If you've checked and they have been uploaded, then make sure that the capitalization is correct. Because class definitions and constructors in CI have to begin with a capital, it's easy to begin the file name with a capital too. If you load a model, say, inside a controller, and give it a capitalized name ($this->load->Mymodel), then Windows and Linux may have different views about calls to $this->mymodel. 115 | > 大小写敏感在微软和 Linux 服务器之间是不同的。 因此如果你在一台windows操作系统的PC上开发你的网站, 然后上传到一台 Linux服务器上,可能会收到出错信息,报告它找不到一些你要装载的模型或者类库。如果你检查过确定它们已经被上传, 你也需要确定大小写是正确的。因为在CI 的类定义和构造函数命名是要求以一个大写字母开始的,而且以一个大写字母开始一个文件名实现也很容易。因此在一个控制器内,你装载一个模型,冠以一个大写字母开始,比如:($this->load->Mymodel),但是windows和 Linux 可能会通过$this->Model调用不同的视图。 116 | 微软和Linux服务器上的大小写敏感是不同的。所以当你在一台Windows操作系统的PC上开发你的网站,然后上传到一台Linux服务器上,可能会收到出错信息,报告找不到一些你要装载的模型或者类库。如果你检查了并确定它们已被上传, 你仍需要确定大小写是正确的。因为在CI的类定义和构造函数命名时,是要求以一个大写字母开头的,以一个大写字母开头的文件命名也很容易。因此在控制器内装载一个模型,应冠以一个大写字母开头的名字,如:($this->load->Mymodel)。而Windows和Linux则可能通过$this->mymodel调用不同的视图。 117 | 118 | > As an extreme example of server differences, I once began to write a controller, decided to make it a model instead, and so saved it in the model folder without realizing that I had left the first few lines as: 119 | > 作为不同服务器的一个极端例子, 我有一次开始写一个控制器,并决定修改使它成为一个模型, 我把它保存在moel目录中,却没有意识到我已经写了头几行代码如下: 120 | 作为服务器差异的一个极端例子,我有一次写一个控制器,后决定将其修改为一个模型,我把它保存在model目录中,却没有意识到我在开头已经写了几行代码: 121 | 122 | > class Myclass extends Controller { 123 | > function Myclass() { 124 | > parent::Controller(); 125 | 126 | 127 | > instead of changing them to: 128 | > 而不是把它改成: 129 | 而不是把它改成: 130 | 131 | > class Myclass extends Model { 132 | > function Myclass() { 133 | > parent::Model(); 134 | 135 | 136 | > Running locally on Xampplite, this did not throw an exception. Transferred to a remote Linux server, it immediately failed (and you can imagine how long it took to track down…). 137 | > 在本地的Xampplite上运行,这没有出错。 迁移到一个远程的Linux服务器上, 立刻报错。(而且你能想像调试它花费了多长时间…) 138 | 在本地的Xampplite上运行,没有出错。但迁移到一个远程的Linux服务器上时,立刻报错。(你应该能想像调试它花费了多长时间……) 139 | 140 | > Some PHP functions also appear to behave differently on different operating systems: for instance, include_once() is case insensitive on Windows but not on other systems. That's not specifically a CI issue, though. 141 | > 一些 PHP 函数在不同的操作系统上似乎也有不同的行为表现: 举例来说, include_once()在windows上是大小写敏感的,但在其它系统上不是。虽然这与CI本身无关。 142 | 一些PHP函数在不同的操作系统上也有不同的表现:举例来说,include_once()在windows上是大小写敏感的,但在其它系统上不是。虽然这与CI本身没什么关系。 143 | 144 | > Also, your database may be a different version—many ISPs are very traditional, running MySQL 3.23 for instance! This seems to cause some incompatibilities, which means that uploading a database by a SQL query is less easy than it should be. (For instance, it may not accept comments on db tables.) 145 | > 同时,你的数据库可能是一个不同的版本-许多ISP还在使用MySQL 3.23! 这似乎引起一些不兼容, 这意味着,通过SQL查询上传一个数据库不是很容易实现。(举例来说,它可能不接受数据表的提交。) 146 | 同时,你的数据库也可能不是同一个的版本——许多ISP还在使用MySQL 3.23!这也许引起一些不兼容,这意味着,通过SQL上传一个数据库不是很容易实现的。(例如,它可能不接受数据表的提交。) 147 | 148 | > Linux has a different system of file permissions to Windows. Make sure that you have the correct permissions on your files and folders. Certain CI file permissions must be set correctly before the system can work. 149 | > Linux与windows相比,有一个不同的文件权限管理系统。 确定你有对应的文件和目录的权限。CI有几个目录文件的权限在它能够正常运行前必须正确设置。 150 | Linux与Windows相比,有一个不同的文件权限管理系统。请确定你有对应的文件和目录的权限。CI有几个目录文件的权限在它能够正常运行前必须正确设置。 151 | 152 | > Diagnostic Tools 153 | > 诊断工具 154 | 诊断工具 155 | 156 | > The first line of the index.php file is: 157 | > index.php文件的第一行是: 158 | index.php文件的第一行是: 159 | 160 | > error_reporting(E_ALL); 161 | 162 | 163 | > which displays any PHP errors on your screen, like this: 164 | > 会在你的屏幕上显示所有的 PHP 错误。 165 | 这会在屏幕上显示所有的PHP错误。 166 | 167 | > Obviously, error reports like this look bad, and may give hackers too much information, so for the production version you alter this to: 168 | > 很显然,这种错误报告很糟糕,可能给黑客太多的信息,所以在产品服务器上你应该改成: 169 | 很显然,这种错误报告很糟糕,可能会给黑客太多信息,所以在产品服务器上你应该改成: 170 | 171 | > error_reporting;(0) 172 | 173 | 174 | > But then, any problems may simply result in a blank screen, with no helpful diagnostic information. You may have to turn error reporting back on, until you have got the site running. One compromise is to set it to an intermediate level, such as: 175 | > 但是然后,任何的问题可能只是造成一个空白的屏幕,没有可提供帮助的诊断信息。 你可能必须把错误报告再打开直到你已经使网站正常运行。 一个折中的做法是把它设定为一个中间状态, 像是: 176 | 但是,很多问题都可能只是造成一个白屏,没有可供参考的诊断信息。这时你可能必须把错误报告再打开,直到你已经使网站可以正常运行。一个折中的做法是把它设定为一个中间状态,像是: 177 | 178 | > error_reporting(E_ERROR); 179 | 180 | 181 | > This will prevent 'warnings' but will still give you information about serious problems. 'Warnings' are usually conditions that don't stop the programme from executing, but may point to other underlying issues that you hadn't considered. 182 | > 这将会避免 'warning' 但是仍然会给你关于严重的问题信息。 'warning' 通常不会中止程序的执行, 但是可能转向其它你没有考虑到的问题。 183 | 这将会避免“warnings”,但仍可给你关于严重问题的信息。“warnings”通常不会中止程序的执行,但可能会引发其它你没有考虑到的问题。 184 | 185 | > The CI Profiler class—see Chapter 8—is also very useful: it shows you what queries you are doing, and what is in the POST array. 186 | > CI Profiler 类-见第 8 章-也非常有用: 它显示你正在做什么查询, POST数组的内容是什么。 187 | CI的Profiler类——详见第8章——也非常有用:它可以显示你正在做什么查询,以及POST数组的内容是什么等。 188 | 189 | > Various other tools I have found useful when things don't work: 190 | > 当这些工具都不起作用时,需要使用其它的工具,下面列出一些我已经发现的其它工具: 191 | 当上述工具都不起作用时,就需要使用其它的工具,下面列出了我找到的一些工具: 192 | 193 | > 1. Set CI to print a log file. (Done from the config file—see Chapter 8—you need to set: 194 | > 1. 设定 CI 开启日志文件。(通过修改 config 文件实现-见第 8 章-你需要设定: 195 | 1. 设定CI开启日志文件。(可通过修改config文件实现,详见第8章): 196 | 197 | 198 | > $config['log_threshold']=4; 199 | 200 | 201 | > 4 shows all messages, including just notices and warnings; sometimes theseare pointers to an underlying problem. Then look at the log (printed in/system/logs, filed by date.) This will tell you which parts of the CI system have been called, so you can at least see where the process stopped. (Set thevalue back to 0 to prevent further logging. Remember to do this, and to removethe log files when you've finished: it's amazing how much space they take up.) 202 | > 4显示所有的信息, 包括notices和warnings; 有时这些会显示潜在的问题。 然后查看日志文件 (保存在/system/logs中.) 这将会告诉你哪一个 CI 部分已经被调用,因此,你能至少能看到程序中止的地方。 (把值设定回 0 会停止日志记录。 记得这样做, 调试完毕后请删除日志文件: 它尺人地占用空间。) 203 | “4”显示所有的信息,包括notices和warnings,有时这会显示出潜在的问题。然后查看日志文件(保存在/system/logs中,依日期排序),这将会告诉你CI的哪个部分已经被调用,因此,你能至少能看到程序中止的地方。(把值设定回“0”会停止日志记录。请记得要这样做,调试完毕后删除日志文件:它非常占用空间。) 204 | 205 | > 2. If you can access them, print out the PHP server and session variables: 206 | > 2. 如果你能存取他们, 打印出 PHP 服务器和会话变量: 207 | 如果你能取得PHP的服务器和会话变量,请输出它们: 208 | 209 | > print_r($_SERVER) 210 | 211 | > and: 212 | > 而且: 213 | 以及: 214 | 215 | > print_r($_SESSION) 216 | 217 | 218 | > and use them to check that the document_root and script_filename values are what you expect. If not, you may need to adjust your config file values for base_url and server You can also see if there is an [HTTP_COOKIE]value set, which will show you if your session class is enabled and working. 219 | > 而且使用他们检查 document_root 和 script_filename 值是不是你意料之中的。如果不是,你可能需要调整config文件中的base_url,server的值的设置,你还可以看一下是否有 [HTTP_COOKIE]的设置,它会显示是否你的session类能够工作。 220 | 并使用他们检查document_root和script_filename的值是不是你所预期的。如果不是,你可能要调整config文件中的base_url、server的设置,你还可以看一下是否有[HTTP_COOKIE]的设置,它会显示是否你的session类能够工作。 221 | 222 | > 3. Check what CI has loaded into its superobject by using PHP's methods: 223 | > 3. 用PHP的方法检查 CI 把什么装载进它的“超级对象”: 224 | 用PHP的方法检查CI把什么装载进它的“超级对象”: 225 | 226 | > get_declared_classes(); 227 | 228 | > and: 229 | > 和: 230 | 以及: 231 | 232 | > get_class_methods(); 233 | 234 | > 4. CI's own show_error() function is only a means of formatting error reportsthat you generate. So including the following line in your code, say at somebranch that should not be reached: 235 | > 4. CI 自己的 show_error() 函数只是格式化生成的错误报告. 因此在你的代码中加入下面的这一行,可以显示出程序运到到哪一个命令分支: 236 | CI自己的show_error()函数只是格式化生成的错误报告。因此在代码中加入下面的这一行,可以显示出程序没有运行哪一个命令分支: 237 | 238 | > show_error('test of error function'); 239 | 240 | 241 | > would result in your screen showing: 242 | > 会在你的屏幕上显示: 243 | 会在屏幕上显示: 244 | 245 | > test of error function 246 | 247 | 248 | > I don't find that very useful. What I want is a system that will give me full, helpful error reports, when and where I want them, but won't show them when I don't want them to appear. I wrote my own function, which reads: 249 | > 我没有发现这非常有用。 当我想要系统在我需要时给我一个完整的有帮助的错误报告, 在何时以及哪里找到他们, 但是当我不想要他们出现的时候将不显示他们。 我需要编写我自己的函数,如下: 250 | 我并没有发现这多有用。如果希望系统在必要的时间和位置给我一个完整的有帮助的错误报告,且当我不想要的时候就不显示它们,就得编写我自己的函数了,如下: 251 | 252 | > function reportme($file, $line, $message) 253 | > { 254 | > $obj =& get_instance(); 255 | > if (isset($_POST)) { 256 | > $bert = print_r($_POST, TRUE); 257 | > } else { 258 | > $bert = 'no post array'; 259 | > } 260 | > if (isset($_SESSION)) { 261 | > $sid = print_r($_SESSION, TRUE); 262 | > } else { 263 | > $sid = 'no session array'; 264 | > } 265 | > $time = Gmdate("H:i j-M-Y"); 266 | > /*full report*/ 267 | > $errorstring = "$time - $file - $line: $message: POST array: $bert SESSION array: $sid\n"; 268 | > /*short report*/ 269 | > $shortstring = "$file - $line: $message"; 270 | > /*set $setting to 'test' if you want to write to the screen*/ 271 | > $setting = 'test'; 272 | > if ($setting == 'test') { 273 | > echo $errorstring; 274 | > } 275 | > /*set $action to 'log' if you want to log errors*/ 276 | > $action = 'log'; 277 | > if ($action == 'log') { 278 | > $filename = $obj->config->item('errorfile'); 279 | > $fp = fopen("$filename", "a+")or die("cant open file"); 280 | > fwrite($fp, $errorstring); 281 | > fclose($fp); 282 | > } 283 | > } 284 | 285 | 286 | > This lives in a library called errors. I have to remember to load the library, and then, whenever I have a section of code that I'm not confident about, I include the function: 287 | > 把它放在一个叫做errors的library文件中。我需要装载这个library, 然后, 每当我对一段代码没有信心的时候,我include这个函数: 288 | 把它放在一个叫做errors的library文件中。我需要装载这个library, 然后, 每当我对某一段代码不是很确定时,我就会include这个函数: 289 | 290 | > $this->errors->reportme(__FILE__,__LINE__,'if the code has reached here it is becase...'); 291 | 292 | 293 | > I can then set the reportme() function to give me a report on the screen, or in my log file. 294 | > 然后我能设定 reportme() 函数在屏幕上显示, 或保存在日志文件中。 295 | 我还可以设定reportme()函数是否屏幕上显示,或是否保存在日志文件中。 296 | 297 | > There are several advantages to a simple method like this. Firstly, I can alter the reportme() function easily, to make it write errors to a file, or to do nothing at all: so I can make all my reports disappear from the screen at once, or come back again, by changing one line of code. 298 | > 这样一个简单的方法的有几个优点:第一,我能容易地修改 reportme() 函数, 使它写错误信息到一个文件, 或全然什么也不做: 因此我能立刻使我所有的错误信息从屏幕消失, 或再回来, 只要修改一行代码。 299 | 这个简单方法有几个优点:第一,我能容易地修改reportme()函数, 让它将错误信息写到一个文件中,或什么也不做:因此我只要修改一行代码,就可以立刻使所有的错误信息从屏幕上消失,或再显示出来。 300 | 301 | > Secondly, let's say I am expecting a variable to have a particular value. (An ID number to be an integer, say.) I make the message as complete and helpful as possible. I try to say what I expected to find (an integer), as well as including the value I actually got. The function call also uses PHP's __FILE__ and __LINE__ 'magic constants' to tell me exactly where it happened. 302 | > 第二,我生成一个包含特别的值的变量。 (一个ID,类型为整型,比方说。) 我生成一个尽可能完整和有帮助的信息。我试着找到一个整数, 连同我实际上得到的值。 函数也用PHP__FILE__ 和 __LINE__魔术常数完整地告诉我它发生的地方。 303 | 第二,比如我生成了一个包含特定值的变量。(如一个ID,类型为整型。)然后生成一个尽可能完整且有帮助的信息。我预期会找到一个整数,也包含了这个值,而我确实找到了。该函数会用“魔术常数”PHP__FILE__和__LINE__完整地告诉我它发生的地方。 304 | 305 | > So, if this particular piece of code becomes a problem when I transfer it to another server, possibly some time after I wrote it, I can immediately find the code, and the text helps me to remember why it is a problem. Six months after you write code, you can't just pick it up straight away, especially if it is late at night and a client is on the phone asking for an explanation! The more helpful the error text, the easier it is to respond sensibly. 306 | > 因此,如果当我把程序迁移到另外的一个服务器的时候,这块特别的代码在我写了一段时间之后如果出现一个问题,我能立刻找到这段代码,而且文字信息帮助我记起它为什么是一个问题。 在你编程完成之后六个月,你不可能马上弄明白, 尤其如果它发生在深夜,一位客户在电话中要求你给他解释什么的!更有帮助的错误本文,将使你容易地作出反应。 307 | 因此,如果我把程序迁移到另一个服务器后出现了一个问题,我能立刻通过这段代码找到问题所在,且文字信息可以帮助我记起它是一个什么问题。在你编程完成六个月后,你不可能马上弄明白,尤其是当深夜一位客户在电话中要求你给他做情况解释时!更有帮助的错误文本,将帮你更容易地作出反应。 308 | 309 | > Thirdly, if the integrity of the site was really critical, I could set the function to email me with error reports. That might result in a very full mailbox during the development phase, but once the site is stable and in use, it might be very useful to have an immediate warning if the site is experiencing problems. You will know about them before your users tell you. 310 | > 第三,如果网站的完整性真的至关紧要,我可以设定函数用电邮把错误报告发送给我。在开发阶段可能造成邮箱爆满,但是一旦网站运行稳定,如果网站遇到问题,有一个即时的警告邮件发给我会是非常有用的。你将会在你的用户知道之前就发现问题。 311 | 第三,如果网站的完整性真的至关重要,可以设定一个函数以电子邮件形式将错误报告发送给我。在开发阶段这可能会造成邮箱爆满,但一旦网站正式运行后,当遇到问题时,有一个即时的警告邮件发给我是非常有用的。你将会在你的用户知道之前就发现问题。 312 | 313 | > Coping with Change in New CI Versions 314 | > 应对新的CI版本带来的变化 315 | 新版CI带来的变化 316 | 317 | > Between 28 February 2006 and 30 October 2006, CI went from its first beta to version 1.5. That's a pretty impressive rate of development. 318 | > 在2006年2月28日到2006年10月30日之间, CI 从它的第一个Beta版升级到1.5版。 那是相当令人印象深刻的升级。 319 | 在2006年2月28日到2006年10月30日之间,CI从它的第一个Beta版升级到了1.5版。这个升级过程令人印象相当深刻。 320 | 321 | > During that time Rick Ellis made several fairly radical changes, particularly to the structure of the site. For the most part, he has been careful to make them backwardly compatible—but not all of them are. If you are new to CI and have downloaded the latest version, you can skip this section. But if you wrote programmes using earlier versions, you may need to check these changes. You may also need to check if you are using CI libraries or plug-ins written by other people. 322 | > 在那期间,Rick Ellis做了一些非常激进的变化, 特别地在网站的结构上。大致上,他已经小心使他们向后兼容-但是并没有完全做到。如果你刚使用 CI 并下载了最新版本,你能够跳越这一个阶段。但是如果你们写了使用较早的版本的程序。如果你正在使用 CIlibraries或者是其他人写的plug-ins。 323 | 在那期间,Rick Ellis做了一些非常激进的更新,特别地在网站的结构上。大致上,他已经注意到需要向后兼容——但并没有完全做到。如果你刚使用CI并下载了最新版本,你可以跳过这一段。但如果你也使用了较早版本的程序,或在用其他人写的CI libraries或plug-ins,你就需要确认一些变化。 324 | 325 | > Rick has grappled with two main problems: 326 | > 瑞克已经努力解决二个主要的问题: 327 | 瑞克已经努力处理了两个主要问题: 328 | 329 | > How to Load Models, and What to Call Them 330 | > 该如何装载模型、和如何调用他们 331 | 应如何装载模型,以及如何调用他们 332 | 333 | > At first, there were no models, just folders for scripts and libraries. There was no provision to initialize them automatically as part of the CI 'super-object'. As a result, you had an MVC system without 'model' files, which seems confusing. 334 | > 起先,没有模型,只是使用目录来管理脚本和libraries。没有准备要自动地初始化它们作为CI超级对象的一部份。结果是, 你有了一个 MVC 系统没有 'M' 文件,似乎令人困惑。 335 | 起先,没有模型,只是通过目录来管理脚本和libraries。并没准备自动地初始化它们作为CI超级对象的一部分。结果有了一个缺少“模型”的MVC系统,这很让人迷惑。 336 | 337 | > As well as this, there are two libraries folders: /system/application/libraries holds any files you write for yourself, while /system/libraries holds the system's own operating files. This may have confused a few people: the two are quite different! You ought to be adding to or altering the former; you probably don't need to alter the latter. (And if you do, you run serious risks of incompatibility if you upgrade to a later CI version: see below.) 338 | > 不仅这样,还有二个libraries目录: /system/application/libraries保存你为自己编写的一些文件, 而/system/libraries保存系统自己的操作文件。 这可能让一些人感到混乱: 这二者之间存在很大的差异!你应该增加到或改变前一个目录中的文件,但你或许不需要改变后者,当然这很容易搞错。 (而且如果你这样做了,如果你对 CI版本升级,你会面临无法兼容的严重危险: 在下面可以看到。) 339 | 不仅这样,还有两个libraries目录:/system/application/libraries保存你为自己编写的一些文件,而/system/libraries则保存系统自己的操作文件。这可能会让人糊涂:这二者之间完全不同!你应该增加或改变前一目录中的文件,但你也许不用改变后者,这很容易搞错。(而且如果你这样做了,当升级CI版本时,你将会面临不兼容的危险:在下面可以看到。) 340 | 341 | > With version 1.3 came a new 'model' class. The User Guide defines models as, "PHP classes that are designed to work with information in your database". When first introduced, CI models connected automatically to the database. However, since Version 1.3.3, you must specifically load the database from inside the model or the controller that calls it. 342 | > 1.3 版带来了一个新的 'Model'类。 用户手册定义模型为" 被设计用来与你的数据库中的数据合作的PHP类 ". 当第一次使用时, CI 模型自动地与数据库连接。 然而, 从1.3.3 版起, 你一定要在模型或控制器中显式地连接数据库。 343 | 1.3版带来了一个新的“Model”类。用户手册中将模型定义为“设计用来与你的数据库中的数据合作的PHP类”。第一次使用时,CI模型自动地与数据库连接。但从1.3.3版起,你就必须要在模型或控制器中显式地连接数据库。 344 | 345 | > Or, when you call the model from the controller, you can do so in this format: 346 | > 或者, 当你从控制器调用模型的时候,你可以以如下格式实现: 347 | 或者,当你从控制器调用模型时以如下格式实现: 348 | 349 | > $this->load->model('Mymodel', '', TRUE); 350 | 351 | 352 | > and then the 'TRUE' loads the model with the default database connection made, as defined in your config file. (The second parameter, left blank here, is an optional alias for the model.) 353 | > 然后 'TRUE' 指定当与默认的数据库连接时才装载模型,正象你的 config 文件所定义的那样。 (第二个叁数, 在这里的空格,是模型的一个可选择的别名.) 354 | 然后“TRUE”指定当与默认的数据库连接时才装载模型,正象你在config文件中所配置的那样。(第二个空白参数是模型中一个可选择的别名。) 355 | 356 | > CI will probably still work if you put the functionality of a 'model' (in the MVC sense) into a 'library' or a (deprecated) 'script', as you had to in the early days when there were no 'models' folders: but you'll have to access the CI resources differently—see the next section! 357 | > 如果你把'模型 '功能(在 MVC 意义上的) 放到一个 'library' 或者一个 (声明:不赞成这么做)脚本之内,CI 或许还可以工作。 较早的版本并没有'model'目录: 你不得不用其它方式存取CI资源-见到下一个区段! 358 | 如果你把(MVC意义上的)“模型”功能放到一个“library”或者一个 (声明:不赞成这这样做)脚本中,CI或许还可以工作。早期版本没有“model”目录:你必须用其它方式存取CI资源——详见下一段! 359 | 360 | > How to Initialize Your Own 'library' Classes 361 | > 如何初始化你自己的 'library' 类 362 | 如何初始化你自己的“library”类 363 | 364 | > Originally, you couldn't make your own classes part of the CI 'super-object'. This was a problem, because it meant that your library code couldn't, for instance, access the database through Active Record, or use other CI libraries, and that became pretty limiting. 365 | > 本来,你无法使你自己的类成为 CI 超级对象的一部份。这是一个问题,因为它意味着你的library代码不能通过AR读写数据库,或使用其他的 CI library,这样的限制太大了。 366 | 本来,你不能让你自己的类成为CI超级对象的一部分。这里有一个问题,因为它意味着你的library代码不能通过AR读写数据库,或者使用其他的CI library,这样就过于受限了。 367 | 368 | > Version 1.2 added the get_instance() function that allows you to access the 'super-object'. (See Chapter 7.) You could include it in your 'library' or 'script' and then use the CI resources. (Unless your new file was a functional script rather than an OO class, of course. However, script files are probably best used for simple low-level functions.) 369 | > 1.2 版本增加了读对类的 get_instance() 函数,允许你读写CI的超级对象(见第七章),你可以在你的 'library'或者脚本中include它,然后使用 CI 资源。(除非你的新文件是一个函数脚本而不是一个 OO 类。当然,脚本文件可能性用来编写简单的基本函数的选择。) 370 | 1.2版本增加了get_instance()函数,允许你读写CI的超级对象(详见第7章),你可以在“library”或者脚本中include它,然后使用CI资源。(除非你的新文件是一个函数脚本而不是一个OO类。当然,脚本形式可能是用来编写简单的底层函数的最佳选择。) 371 | 372 | > Version 1.4 introduced a new system. You had to create two files for each 'library' class. The first was the class itself, say Newclass.php, stored in the application/ libraries folder, and the second, stored in an application/init folder, had to be called init_newclass.php and contained a few standard lines of code that initialized it as part of the 'super-object'. However, you still had to use the get_instance() function to access CI resources. 373 | > 1.4 版引进了一个新的系统。你必须为每个'library'类创建二个文件。第一个是类本身,比如Newclass.php,保存在 application/libraries目录中,第二个,保存在application/init目录中, 必须叫做init_newclass.php 必须包含几个标准代码行,用来初始化,让它成为CI超级对象的一部分,你仍然需要使用 get_instance()函数存取 CI 资源。 374 | 1.4版引进了一个新的系统。你必须为每个“library”类创建两个文件。第一个是类本身,比如Newclass.php,保存在application/libraries目录中;第二个则保存在application/init目录中,必须叫做init_newclass.php,它必须包含几行标准代码,以进行初始化,使其成为CI超级对象的一部分,但你仍要使用get_instance()函数存取CI资源。 375 | 376 | > In version 1.5, the init folder has been deprecated, and initialization happens automatically. You now only need the one file for each 'library' class. 377 | > 在1.5版中, init 文件夹已经被不鼓励使用了,初始化将自动地进行。 每个'library'只需要一个文件。 378 | 在1.5版中,已经不鼓励使用init文件夹了,初始化将自动地进行。每个“library”只需要一个文件。 379 | 380 | > The old scripts folder has also been deprecated. 'Deprecate' in this context, usually means that the thing concerned is till recognized and should still work, but that the developer offers no guarantee that it will do so in all future versions. In other words, don't panic if you still have scripts in a system/application/scripts folder—but don't write any more. 381 | > 旧的脚本目录也已经不鼓励使用了。'不鼓励使用'通常意味着相关的实现方法能够工作,但是开发者应该尽量不要这么做,因为CI不能保证在未来的版本中还支持它。 如果你仍然有一个system/application/scripts目录,不需要紧张-但是也不要再使用它。 382 | 旧的脚本目录也不鼓励使用了。“不鼓励使用”通常意味着相关的实现方法能够工作,但是请开发者尽量不要这么做,因为CI不能保证在未来的版本中还支持它。如果你还有一个system/application/scripts目录,无需紧张——但是请不要再用它了。 383 | 384 | > If you are planning to use libraries or plug-ins written by the CI community, please check first that they are up to date with the latest CI version. There are quite a few around still that were written for 1.4.1 and have separate 'init' files. Updating them isn't difficult, but it does take some care to get it right. 385 | > 如果你正在计划使用由 CI 社区编写的libraries或者plug-ins,请首先检查这些资源是否是为CI的最新版本开发的。 有相当多的是为1.4.1版本开发的,还有另一个'init'文件。 更新它们不困难,但是需要小心行事,确保它们正常工作。 386 | 如果你正在计划使用由CI社区编写的libraries或者plug-ins,请首先检查这些资源是否是为CI的最新版本开发的。有相当多的是专为1.4.1版本开发的,仍包含独立的“init”文件。更新它们不困难,但需小心行事,以确保它们正常工作。 387 | 388 | > So Should I Update If a New CI Version Comes Out? 389 | > 如果新的 CI 版本出来,我应该更新吗? 390 | 如果有了新版CI,我需要更新吗? 391 | 392 | > New versions of CI come out from time to time. They come with comprehensive instructions for updating. Usually, this involves copying a new set of files to your system folder. Sometimes, you need to change config files, or your index.php file, as well, but none of these are major changes and none of them are rocket science. Because the folder structure keeps your application files in their own place, it's usually easy to update the system without touching the applications. 393 | > CI 的新版本时不时会推出。 它们带有如何更新的指南。 通常,这包括拷贝一组新的文件到你的system目录。 有时,你需要改变 config文件, 或者你的 index.php文件。不会有巨大的改变。因为目录结构把你的应用保存在他们自己的位置,这样可以在升级系统时不用涉及到你的应用系统。 394 | 新版CI会不时推出,它们会带有更新指南。通常,这包括一组新的文件需要拷贝到你的system目录中。有时,你还需要更新config文件,或index.php文件。这不会带来巨大改变,因为目录结构已经将你的应用保存在他们自己的位置,这样在升级系统时并不会涉及到应用程序。 395 | 396 | > But, say you've written your killer app in version 1.5. It's uploaded to your production system and working fine. Then, Rick Ellis brings out CI version 1.6 (or 2.8 or whatever…). It has interesting new features, and some bug fixes. Do you upgrade to it? 397 | > 但是, 假如说你已经在 1.5 版中写了一个你的优秀作品. 它被上传到你的生产系统并且运行得很好。 如果Rick推出了CI 1.6 版.(或 2.8 或任何其它的…) 它有一些有趣的新功能、还有一些Bug修正。你是否需要对它进行升级? 398 | 假如说你已经基于1.5版完成了一个优秀作品,它被上传到产品系统中且运行得很好。此时如果Rick推出了CI 1.6版(或2.8,或其它版本……),它有一些有趣的新功能、还有一些Bug修正。你是否需要对它进行升级呢? 399 | 400 | > I would say, 'Yes', if it's a minor upgrade, say between 1.5.2 and 1.5.3. But if it's a major version change, and your existing system is working, leave well alone. You can tell the difference partly from the numbering, but also from the 'change log' published with each upgrade when it comes out. The sort of changes that have been made in CI over the last year fall into three categories: 401 | > 我会说, '是的', 如果它是一个较小的升级, 比如在 1.5.2 和 1.5.3之间,你应该升级. 但是如果它是一个主要的版本变化,而你的现有系统正在工作, 暂缓升级是个比较明智的选择。 你可能从数字部分分辨出版本升级变化大小的程度, 但是也可以从新版本附带的'变化清单'列表得出结论。从去年开始 CI 划分了三个目录来列出三类不同的变化: 402 | 我会说:“是的。”如果它只是一个较小的升级,比如在1.5.2和1.5.3之间,你应该升级。但如果它是一个主要的版本变化,而你现有的系统正在工作,暂缓升级是个比较明智的选择。你可能从数字部分分辨出版本升级变化大小的程度,也可以从新版本附带的“更新列表”中得出结论。从去年开始,CI划分了三种类型来表示不同的变化: 403 | 404 | > Bug fixes: There are surprisingly few of these—CI is excellent code, and most of the base classes have been well tested by hundreds if not thousands of users. 405 | > Bug修正: 令人惊讶地少,CI有优良的代码, 而且大部份的基础类已经被数以千计的使用者精心地测试了上百遍。 406 | Bug修正:令人惊讶的少,CI有优良的代码,大多数基础类已经被数以千计的使用者精心地测试了上百遍。 407 | 408 | > New features:. These appear regularly, but if you managed to build your application without them, will they really be helpful now? 409 | > 新的功能:. 这些经常地出现,但是如果你不使用这些新功能来开发你的应用,它们并不会对你有什么帮助。 410 | 新功能:经常出现,但如果你不使用这些新功能来开发你的应用程序,它们并不会对你有什么帮助。 411 | 412 | > Subtle changes: As I've described, CI has gone through a process of internal evolution, and it may well continue to do so. As you can see from the following table, some of these might be backwardly compatible, or they might require fairly major re-writes of your code. 413 | > 敏感的变化: 就象我已经描述过的, CI 已经经过一个内存的升级的过程,而且它理所当然会继续这么做。你能从下面的列表看到,其中的一些向后兼容, 否则它们可能导致你重写你的部分代码。 414 | 敏感更新:就象我说过的,CI经过了一个内部升级的过程,而且它理所应当地会继续这么做。你可以通过下面的列表看出来,其中一些更新会向后兼容,否则它们可导致你将重写部分代码。 415 | 416 | > Some changes between versions of CI: 417 | > 在 CI 的版本之间的一些变化: 418 | CI版本更新过程中的一些变化: 419 | 420 | > VersionChange Log 421 | > 版本 变化记录 422 | 版本 变化记录 423 | 424 | > 1.2Added a global function named get_instance() allowing the main CodeIgniter object to be accessible throughout your own classes. 425 | > 1.2 增加一个全局函数,名为get_instance(),允许你自定义的读写CI的主对象。 426 | 1.2 增加了一个名为get_instance()的全局函数,允许你的自定义类很容易地读写CI的主对象。 427 | 428 | > 1.3Added support for Models. 429 | > 1.3 增加对模型的支持。 430 | 1.3 增加了对模型的支持。 431 | 432 | > 1.3Added the ability to pass your own initialization parameters to your custom core libraries when using $this->load->library(). 433 | > 1.3 增加传递你自己的初始化参数到客户自定义library能力,你可以这样做:$this->load->library() 434 | 1.3 增加了传递自定义初始化参数到常规核心library的功能,你可以这样做:$this->load->library() 435 | 436 | > 1.3Added better class and function name-spacing to avoid collisions with user developed classes. All CodeIgniter classes are now prefixed with CI_ and all controller methods are prefixed with _ci to avoid controller collisions. 437 | > 1.3 增加较好的类和函数的命名空间-避免冲突。所有的CodeIgniter类开始冠以CI_前缀和所有的控制器方法以_ci为前缀避免控制器命名冲突。 438 | 1.3 增加了较好的类与函数的命名空间——避免冲突。所有的CodeIgniter类开始冠以CI_前缀,所有的控制器方法均以_ci为前缀,从而避免了控制器命名冲突。 439 | 440 | > 1.3.3Models do not connect automatically to the database as of this version. 441 | > 1.3.3 模型不自动连接数据库。 442 | 1.3.3 该版本模型不自动连接数据库。 443 | 444 | > 1.4Added the ability to replace core system classes with your own classes. 445 | > 1.4 增加了用你自定义的类替换核心系统类的能力。 446 | 1.4 增加了用你自定义的类替换核心系统类的功能。 447 | 448 | > 1.4Updated the Models loader function to allow multiple loads of the same model. 449 | > 1.4 升级模型的装载函数,允许对同一模型多次装载。 450 | 1.4 升级了模型的装载函数,允许对同一模型多次装载。 451 | 452 | > 1.4.1Updated plugins, helpers, and language classes to allow your application folder to contain its own plugins, helpers, and language folders. Previously, they were always treated as global for your entire installation. If your application folder contains any of these resources they will be used instead the global ones. 453 | > 1.4.1 更新了plugins, helpers和language类,允许你的应用程序目录包含你自己的plugins, helpers和language类。先前,在安装时它们总是被当作全局的,如果你的应用目录包含了它们中的任一个,你自定义的将会覆盖系统中的这些资源。 454 | 1.4.1 更新了plugins、helpers和language类,允许你的应用程序目录包含你自己的plugins, helpers和language类。之前它们在安装时总是被当作全局的。而现在你的应用目录如果包含了它们中的任一个,自定义的将会替代系统中的这些资源。 455 | 456 | > 1.4.1Deprecated the application/scripts folder. It will continue towork for legacy users, but it is recommended that you create your own libraries or models instead. It was originally added before CI had userlibraries or models, but it's not needed anymore. 457 | > 1.4.1 声明不鼓励使用application/script目录。 但它将会继续为以前的使用者提供正常使用的可能性,但是建议你改为创建你自己的library或model。在CI支持用户自定义library或者model之前,它本来就存在,但是它不再是必不可少的。 458 | 1.4.1 声明了不鼓励使用application/script目录。但它将会为以前的使用者继续保留,但建议你改为创建你自己的library或model。在CI支持用户自定义library或者model之前,它本来就存在,但是它已不再是必须的了。 459 | 460 | > 1.5Added the ability to extend libraries and extend core classes, in additionto being able to replace them. 461 | > 1.5 增加能力扩展library和核心类的功能,而且也能替换它们。 462 | 1.5 增加了扩展library和扩展核心类的功能,而且也能替换它们。 463 | 464 | > 1.5Deprecated init folder. Initialization happens automatically now. 465 | > 1.5 声明不鼓励使用init 文件夹。初始化现在自动进行。 466 | 1.5 声明了不鼓励使用init文件夹。现在的初始化开始自动进行了。 467 | 468 | > Don't misunderstand me. All of these are sensible changes and all of them are improvements. If you are starting a new project, start with the latest CI version. But if you wrote code using version 1.3, say, you will find that your scripts folder is deprecated and your models don't automatically connect to the database any more. Personally, I would leave that code running on version 1.3 of CI, rather than try to upgrade it. Life's too short. 469 | > 不要误解我。 这些全部是有意义的改变,并且他们全部是对CI的升级。 如果你开始一个新的项目, 请使用最新的 CI 版本。但是如果你使用1.3版开发应用,你会发现你的scripts目录被声明不鼓励使用,而且你的模型也不会自动连接数据库。我个人在使用CI的1.3 版,而不尝试升级它。 生命苦短。 470 | 不要嫌我啰嗦,这些都是重要的更新与改良。如果你启动了一个新项目,请使用最新的CI版本。但是如果你正在使用1.3版开发应用,你会发现scripts目录被声明不鼓励使用,而且模型也不会自动连接数据库。就个人而论,我曾经坚持在CI的1.3版而不去升级它,浪费了很多时间。 471 | 472 | > How to Add On to CI's Basic Classes 473 | > 如何修改CI的基础类 474 | 如何修改CI的基础类 475 | 476 | > Normal users are unlikely to need to alter the base CI classes. It's a pretty good framework, it does a lot of things, and after all, the point of a framework is to make thing easy, right? However, if you must …. 477 | > 一般使用者不可能需要改变基本的CI类。 它是相当好的框架,它做许多事物, 而且毕竟,使用框架会使做事更容易, 对不对? 然而, 如果你一定…. 478 | 一般使用者可能无需改变CI基础类。它具备相当好的框架,能做出许多东西来,使用框架不是会让事情更容易吗?当然,如果你一定要做的话…… 479 | 480 | > CI is open source, and you can see all the code as soon as you download it. This includes the basic libraries that make CI work (stored in system/libraries) as well as the ones you wrote in system/application/libraries.) So it has always been possible to change CI any way you like. 481 | > CI 是开源产品, 一旦下载你能看到所有的代码。 这包括使 CI 工作 (在system/libraries保存)的基本library以及你一旦编写后保存system/application/libraries的你自己的libraries,因此你可能改变CI让它以你喜欢的方式工作。 482 | CI是开源产品,下载后你就能看到所有的代码。这包括使CI工作的基本library(保存在system/libraries中)与你自己的libraries(保存在system/application/libraries中),所以你可以改变CI,使其以你喜欢的方式工作。 483 | 484 | > Changing system library files has two problems, however: 485 | > 修改系统libraries文件有二个问题,就是: 486 | 修改系统libraries文件存在两个问题,就是: 487 | 488 | > There's no guarantee that your new code will be compatible with the rest of CI, or with updated versions. This may lead to subtle or strange errors that won't be easy to track down. If you later update your CI version, the system folder is likely to be changed. 489 | > 。 没有保证,你的新密码是否会与 CI 的其余部分兼容,或与更新的版本兼容。这可能导致不容易跟踪敏感或者奇怪的错误。如果你稍后升级你的 CI 版本,系统目录可能被改变。 490 | 谁也不能保证你的新代码与CI的其他部分或更新的版本兼容。这可能会导致不易跟踪的、敏感的或奇怪的错误。如果你稍后升级你的CI版本,系统目录也可能会随之改变。 491 | 492 | > ·The library file you altered may well be over-written and updated, so you'd have to go through your changes and transfer them to the updated version. 493 | > 。 你改变过去的libraries将被新的文件覆盖或升级, 因此你需要维护你自己的修改并把它们迁移到升级的版本。 494 | 你修改过的library将被新的文件覆盖或更新,因此你需要自行修改并将其更新到升级的版本中。 495 | 496 | > However, since version 1.5, there are now two sensible 'work-arounds' for tinkering with the CI library classes (except for the underlying 'database' and 'controller' classes, which you touch at your peril.) 497 | > 不过,从 1.5 版起, 现在针对修改CI类库有二个有意义的机制(除了针对'数据库'和'控制器'类,触及这两个都很危险.) 498 | 不过,对可能有人会胡乱修改CI类库的情况,从1.5版起增加了两个明确的“工作区”。(不包括基本的“数据库”和“控制器”类,这两个都很危险,请不要自行修改。) 499 | 500 | > · Firstly, you can create a file with the same name as any of the system baseclasses in your /system/application folder. The system then uses this one,in preference to the standard one in the /system folder. This requires exactnaming conventions—see the online User Guide. It also requires you to copyall the functionality in the existing class as well as your own additionsor changes. 501 | > 第一,无论在哪个操作系统中,你能在你的 /system/application目录中创建一个与系统基础类同名的文件。系统会优先使用这一个,如果这个文件不存在或不可用则使用/system目录中的那个。这需要有精确的命名限制-详见用户手册。它也需要你复制所有在现有的类中存在的功能,让它们和你自己修改过的那些一起工作。 502 | 第一,当你在/system/application目录中创建一个与系统基础类同名的文件,系统会优先使用这一个;如果该文件不存在或不可用时,则使用/system目录中的那个。该操作有明确的命名限制——详见用户手册。它还需要你复制所有在现有的类中存在的功能,让它们和你改过的那些类一起工作。 503 | 504 | > · Secondly, and more conveniently, you can create a new class that extends the system class. (So it's perhaps best referred to as a 'sub-class'.) Again, there arenaming conventions—see the online User Guide. Extending the underlyingsystem class means that your new sub-class inherits all the resources of theunderlying CI class, but adds a few extra methods of your own. This shouldmean that, if you update your CI version, the underlying CI class will bereplaced, but your new sub-class (which you should put in the system/application folder) will be left untouched. 505 | > 第二, 更方便地,你能从现有系统类派生出一个新类。(因此可能派生一个子类是更好的做法),当然也有命名限制,详见用户手册。继承一个系统类意味着你的新子类潜在继承了CI类中的所有资源,并增加几个你自己的额外方法。这应该意味着,如果你升级你的 CI版本,祖先类将会被替换,但是你的新子类(你应该把它放在system/application目录)将安然无恙。 506 | 第二,更方便地,你可以从现有系统类中派生出一个新类。(派生一个子类可能是更好的做法。)这当然也有命名限制,详见用户手册。继承一个系统类意味着你的新子类潜在地继承了CI类中的所有资源,并增加了几个你的额外方法。这也许意味着,如果你升级了CI版本,祖先类将会被替换,但是你的新子类(应该将其放在system/application目录中)将安然无恙。 507 | 508 | > However, neither of these methods will guarantee that your code is (or remains) compatible with the rest of CI. 509 | > 然而, 两者都不能保证你的代码与CI的其它部分完全兼容。 510 | 然而,上述两种方式都不能保证你的代码与CI的其它部分完全兼容。 511 | 512 | > Looking through the CI online forums, there are various suggestions for extending the Validation, Unit Testing, and Session classes. Unit Testing, for example, only has two functions and a limited number of comparisons. Perhaps you want a function to show up errors in red, so they stand out when the test results are returned? 513 | > 通过CI在线论坛,有扩充校验类、单元测试和会话类的各种不同的建议。 单元测试, 举例来说,只有二个函数和比较有限的字符数。 也许你想要一个函数,用红色显示错误信息,因此,当测验结果被返回时,他们会显得比较醒目 ? 514 | 去看看CI社区,上面有对各种扩充校验类、单元测试和会话类的不同建议。以单元测试为例,只有二个函数和比较有限的字符数做比较。如果你希望有一个函数,当测试结果返回时,以比较醒目的红色标识错误信息? 515 | 516 | > If you wanted to make extensive use of some other testing function, it would be simpler to add it in via a sub-class, extending Unit Testing, than to write it out in the controller each time you called Unit Testing. 517 | > 如果你想要扩充一些其他的测试函数,通过一个子类把它加入会是比较简单的,每次在控制器中编写代码调用单元测试。 518 | 或者你希望扩充一些其他的测试函数,比较简单的做法是通过一个子类将其加入。扩展到单元测试上,即当你每次调用单元测试时,将其写入控制器中。 519 | 520 | > If you wanted to do this, you'd start your new sub-class this way: 521 | > 如果你想要这样做,你可以这样开始你的新子类: 522 | 如果你想这样做,可以这样开始新子类: 523 | 524 | > class MY_Unit_test extends CI_Unit-test { 525 | > function My_Unit_test() { 526 | > parent::CI_Unit_test(); 527 | > } 528 | 529 | 530 | > function newfunction() { 531 | > //new code here! 532 | > } 533 | > } 534 | 535 | 536 | > Notice three things here: 537 | > 在这里注意三件事: 538 | 这里需要注意三件事: 539 | 540 | > ·The name of the underlying unit testing class is CI_Unit_test, even though the filename of the class code is system/libraries.unit_test. 541 | > 。 单元测试类的名称是CI_Unit_test,即使类的代码文件名是system/libraries.unit_test。 542 | 单元测试类的名称是CI_Unit_test,即使类代码的文件名为system/libraries.unit_test。 543 | 544 | > ·If you need to use a constructor in your sub-class, make sure you extend the parent constructor first, as here. 545 | > 。 如果你需要在你的子类中使用一个构造函数,确定你首先在里面调用父类的构造函数。 546 | 如果你需要在你的子类中使用一个构造函数,请先确定在里面调用父类的构造函数。 547 | 548 | > ·Your new sub-class name should be prefixed with MY_, and saved as application/libraries/MY_unit_test.php. (Unlike the main classes, where the CI_ prefix is part of the class name but not of the filename, here the MY_ prefix is part of both.) 549 | > 。 你的新子类名称应该与 MY_ 前缀并保存为application/libraries/MY_unit_test.php。(不像系统中那些主要的类, 它们是以CI_为前缀,但是不是文件名, 在这里MY_前缀是两者的一部份.) 550 | 该新子类名称应该为MY_前缀并保存为application/libraries/MY_unit_test.php。(不像系统中的主要类,是以CI_为前缀,而不是文件名,在这里MY_前缀其实是二者的一部分。) 551 | 552 | > Once you've created your sub-class, you load it like this: 553 | > 一旦你已经创建你的子类,你像这样装载它: 554 | 如果你已经创建了你的子类,你可以这样装载它: 555 | 556 | > $this->load->library('unit_test'); 557 | 558 | 559 | > In other words, exactly the same as before you wrote the sub-class; and you call a function in the same way too, except that this time you can call not only the existing unit test functions, but also any new ones you've written yourself: 560 | > 换句话说, 完全地与你以前编写的了类相同; 而且你以同样的方式调用一个函数,但是这次你不但能调用原来的单元测试函数,还能调用你自己编写的新函数: 561 | 换句话说,新子类与你以前编写的子类完全相同,而且会以同样的方式调用函数,不过此时你不但能调用原来的单元测试函数,还能调用你自己编写的新函数: 562 | 563 | > $this->unit_test->newfunction(); 564 | 565 | 566 | > When you next update your CI installation, the unit test library in the system folder will be overwritten, but the one in the application folder won't, so your code will still be there. Of course, you'll need to check that the updated system library is still compatible with your own code. 567 | > 当你以后升级你的 CI 的时候,在系统文件夹中的单元测试类库将会覆盖,但是那个在application目录中的将不会,因此你的代码将会仍然在那里。 当然,你将会需要检查被更新的系统类是否仍然与你自己的代码兼容。 568 | 在你以后升级CI时,在系统文件夹中的单元测试类库将会覆盖,但在application目录中的那个不会被覆盖,所以你的代码还会在那里。当然,你还需要检查更新的系统类是否依然与你自己的代码兼容。 569 | 570 | > Summary 571 | > 摘要 572 | 摘要 573 | 574 | > In this chapter, we've seen some of things that can go wrong when you try to transfer your system from a local server to a remote one. This may involve: 575 | > 在这一章里,当你尝试迁移一个本地应用到远程服务器的时候,有些东西可能会出错。 这可能包括: 576 | 在这一章里,当你尝试迁移一个本地应用到远程服务器时,可能会出现一些问题。这包括: 577 | 578 | > · A different version of PHP or MySQL 579 | > 。 PHP 或 MySQL 的版本差异 580 | PHP或MySQL的版本差异 581 | 582 | > · A different operating system 583 | > 。 不同的操作系统 584 | 操作系统的差异 585 | 586 | > In particular, we've looked at case sensitivity, PHP differences, and MySQL issues. We've also looked at diagnostic tools. 587 | > 特别地,我们分析了大小写敏感问题, PHP 差异、和 MySQL 问题。 我们也谈及几个诊断工具。 588 | 特别地,我们分析了大小写敏感问题、PHP差异与MySQL问题。我们还讨论了几个诊断工具。 589 | 590 | > Then we looked at the CI's updates. These have all been major improvements, but my advice is, if you have a system working on the current CI version and a new one comes out, think carefully before you upgrade. 591 | > 然后我们分析了CI 的升级。 这些都带来了重要的进步, 但是我的忠告是, 如果你在现在的 CI 版本上工作得很好,如果CI有新的版本推出,仔细评估是否需要升级和如何升级。 592 | 然后我们分析了CI的升级。对这些重要的进步,我的建议是,如果你在现在的CI版本上工作得很好,当CI有新的版本推出时,请仔细评估是否需要升级以及如何升级。 593 | 594 | > Lastly, we looked at the pros and cons of adding to CI's basic classes. Most users won't need to do this, but if you want to, I strongly suggest that the best way to do it is to sub-class an existing library class. 595 | > 最后,我们分析修改 CI 基础类的正反两方面。 大多数的使用者将不需要这么做。但是如果你确信需要这么做,我强烈建议:实现它的最好方式是从一个现存的library类中派生一个子类。 596 | 最后,我们分析了修改CI基础类的正反面因素。其实大多数的使用者无需这样做。但如果你确信的确需要这样做,我强烈建议:实现它的最好方式是从一个现存的library类中派生一个子类。 -------------------------------------------------------------------------------- /_docs/12.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_docs/12.txt -------------------------------------------------------------------------------- /_docs/13.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_docs/13.txt -------------------------------------------------------------------------------- /_docs/14.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_docs/14.doc -------------------------------------------------------------------------------- /_docs/14.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_docs/14.txt -------------------------------------------------------------------------------- /_docs/15.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_docs/15.txt -------------------------------------------------------------------------------- /_docs/2.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_docs/2.doc -------------------------------------------------------------------------------- /_docs/2.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_docs/2.txt -------------------------------------------------------------------------------- /_docs/3.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_docs/3.doc -------------------------------------------------------------------------------- /_docs/3.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_docs/3.txt -------------------------------------------------------------------------------- /_docs/3_old.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_docs/3_old.doc -------------------------------------------------------------------------------- /_docs/4.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_docs/4.doc -------------------------------------------------------------------------------- /_docs/4.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_docs/4.txt -------------------------------------------------------------------------------- /_docs/4_old.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_docs/4_old.doc -------------------------------------------------------------------------------- /_docs/5.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_docs/5.doc -------------------------------------------------------------------------------- /_docs/5.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_docs/5.txt -------------------------------------------------------------------------------- /_docs/6.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_docs/6.doc -------------------------------------------------------------------------------- /_docs/6.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_docs/6.txt -------------------------------------------------------------------------------- /_docs/7.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_docs/7.doc -------------------------------------------------------------------------------- /_docs/7.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_docs/7.txt -------------------------------------------------------------------------------- /_docs/8.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_docs/8.doc -------------------------------------------------------------------------------- /_docs/8.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_docs/8.txt -------------------------------------------------------------------------------- /_docs/9.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_docs/9.doc -------------------------------------------------------------------------------- /_docs/9.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_docs/9.txt -------------------------------------------------------------------------------- /_docs/CodeIgniter.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_docs/CodeIgniter.pdf -------------------------------------------------------------------------------- /_docs/index.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_docs/index.txt -------------------------------------------------------------------------------- /_docs/preface.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_docs/preface.txt -------------------------------------------------------------------------------- /_images_source/13.5.1.1_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_images_source/13.5.1.1_1.png -------------------------------------------------------------------------------- /_images_source/13.5.1.2_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_images_source/13.5.1.2_1.png -------------------------------------------------------------------------------- /_images_source/3.2-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_images_source/3.2-1.png -------------------------------------------------------------------------------- /_images_source/3.8.4-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_images_source/3.8.4-1.png -------------------------------------------------------------------------------- /_images_source/CodeIgniter-01.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_images_source/CodeIgniter-01.jpg -------------------------------------------------------------------------------- /_images_source/CodeIgniter-02.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_images_source/CodeIgniter-02.jpg -------------------------------------------------------------------------------- /_images_source/CodeIgniter-03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_images_source/CodeIgniter-03.png -------------------------------------------------------------------------------- /_images_source/CodeIgniter-04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_images_source/CodeIgniter-04.png -------------------------------------------------------------------------------- /_images_source/CodeIgniter-05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_images_source/CodeIgniter-05.png -------------------------------------------------------------------------------- /_images_source/CodeIgniter-06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_images_source/CodeIgniter-06.png -------------------------------------------------------------------------------- /_images_source/CodeIgniter-07.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_images_source/CodeIgniter-07.png -------------------------------------------------------------------------------- /_images_source/CodeIgniter-08.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_images_source/CodeIgniter-08.png -------------------------------------------------------------------------------- /_images_source/CodeIgniter-09.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_images_source/CodeIgniter-09.png -------------------------------------------------------------------------------- /_images_source/CodeIgniter-10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_images_source/CodeIgniter-10.png -------------------------------------------------------------------------------- /_images_source/CodeIgniter-11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_images_source/CodeIgniter-11.png -------------------------------------------------------------------------------- /_images_source/CodeIgniter-12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_images_source/CodeIgniter-12.png -------------------------------------------------------------------------------- /_images_source/CodeIgniter-13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_images_source/CodeIgniter-13.png -------------------------------------------------------------------------------- /_images_source/CodeIgniter-14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_images_source/CodeIgniter-14.png -------------------------------------------------------------------------------- /_images_source/CodeIgniter-15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_images_source/CodeIgniter-15.png -------------------------------------------------------------------------------- /_images_source/CodeIgniter-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_images_source/CodeIgniter-16.png -------------------------------------------------------------------------------- /_images_source/CodeIgniter-17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_images_source/CodeIgniter-17.png -------------------------------------------------------------------------------- /_images_source/CodeIgniter-18.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_images_source/CodeIgniter-18.png -------------------------------------------------------------------------------- /_images_source/CodeIgniter-19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_images_source/CodeIgniter-19.png -------------------------------------------------------------------------------- /_images_source/CodeIgniter-20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_images_source/CodeIgniter-20.png -------------------------------------------------------------------------------- /_images_source/CodeIgniter-21.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_images_source/CodeIgniter-21.jpg -------------------------------------------------------------------------------- /_images_source/CodeIgniter-22.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_images_source/CodeIgniter-22.jpg -------------------------------------------------------------------------------- /_images_source/CodeIgniter-23.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_images_source/CodeIgniter-23.jpg -------------------------------------------------------------------------------- /_images_source/CodeIgniter-24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_images_source/CodeIgniter-24.png -------------------------------------------------------------------------------- /_images_source/CodeIgniter-25.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_images_source/CodeIgniter-25.png -------------------------------------------------------------------------------- /_images_source/CodeIgniter-26.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_images_source/CodeIgniter-26.png -------------------------------------------------------------------------------- /_images_source/CodeIgniter-27.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_images_source/CodeIgniter-27.png -------------------------------------------------------------------------------- /_images_source/CodeIgniter-28.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_images_source/CodeIgniter-28.png -------------------------------------------------------------------------------- /_images_source/CodeIgniter-29.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_images_source/CodeIgniter-29.png -------------------------------------------------------------------------------- /_images_source/CodeIgniter-30.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_images_source/CodeIgniter-30.png -------------------------------------------------------------------------------- /_images_source/CodeIgniter-31.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_images_source/CodeIgniter-31.png -------------------------------------------------------------------------------- /_images_source/CodeIgniter-32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_images_source/CodeIgniter-32.png -------------------------------------------------------------------------------- /_images_source/CodeIgniter-33.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_images_source/CodeIgniter-33.png -------------------------------------------------------------------------------- /_images_source/CodeIgniter-34.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_images_source/CodeIgniter-34.png -------------------------------------------------------------------------------- /_images_source/CodeIgniter-35.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_images_source/CodeIgniter-35.png -------------------------------------------------------------------------------- /_images_source/CodeIgniter-36.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_images_source/CodeIgniter-36.png -------------------------------------------------------------------------------- /_images_source/CodeIgniter-37.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_images_source/CodeIgniter-37.png -------------------------------------------------------------------------------- /_images_source/CodeIgniter-38.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_images_source/CodeIgniter-38.png -------------------------------------------------------------------------------- /_images_source/CodeIgniter-39.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_images_source/CodeIgniter-39.png -------------------------------------------------------------------------------- /_images_source/CodeIgniter-40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_images_source/CodeIgniter-40.png -------------------------------------------------------------------------------- /_images_source/CodeIgniter_cover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_images_source/CodeIgniter_cover.png -------------------------------------------------------------------------------- /_images_source/header.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_images_source/header.png -------------------------------------------------------------------------------- /_other/template.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_other/template.html -------------------------------------------------------------------------------- /_other/代码勘误.txt: -------------------------------------------------------------------------------- 1 | 3.7.1 2 | $data['mytext'] = "Hello, $name, now we're getting dynamic!"; 3 | 此句改为$data['mytext'] = "Hello ".$name." now we're getting dynamic!"; 4 | 5 | 5.6 6 | 去掉function Display()中的$this->load->library('errors'); 7 | 1.7.0版本中已经没有errors这个包了,变成了Exceptions包 -------------------------------------------------------------------------------- /_other/数据勘误.txt: -------------------------------------------------------------------------------- 1 | 1.1 第一行将“codeigniter”改为“CI”,因为在本章第一段文字中已经说明“以下简称 CI” 2 | 2.2 第二行,1.7.0才是最新版的,改了它。文件大小应该是891KB 3 | 2.3 第三行 “你能把”改为“可以把” 4 | 第四行 第一句改为“application是项目文件的存放目录” 5 | 第四段中的“Codeigniter”改为“CI”,原因同1.1 6 | 第三章 7 | 第一句“既然我们已经安装了CI”中的“我们”去掉,整句变为“既然已经安装了CI,那我们就开始了解它是如何工作的吧。” 8 | 第二段“如果你喜欢的话你可以”一句中的第二个你字去掉,改为“如果你喜欢的话可以”或者“如果喜欢的话你可以” 9 | 第三段 “特别地,”改为“特别”,并且去掉后边的逗号。 10 | 第五段 “codeigniter语法规则”改为“CI语法规则”,原因同1.1 11 | 3.2 标题里的CI变为“Codeigniter”,前两章的所有标题都是全写 12 | 3.4 同3.2 13 | 3.8 同3.2 14 | 3.8.2 第二行第一个“我”字去掉 15 | 3.8.3 第三行 “作”改为“做” 16 | 3.8.5 第二行 将“site和/”改为“site URL” 17 | 18 | 第七章 19 | 20 | 第一段和第二段中的codeigniter应该为简写 21 | 22 | 注:各章节均有不同程度的标题问题,同3.2,是否将所有章节的标题都用全写形式呢(Codeigniter) 23 | -------------------------------------------------------------------------------- /_other/校对记录.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/_other/校对记录.txt -------------------------------------------------------------------------------- /about_the_author.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/about_the_author.html -------------------------------------------------------------------------------- /about_the_reviewers.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/about_the_reviewers.html -------------------------------------------------------------------------------- /build.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | hhc codeigniter -------------------------------------------------------------------------------- /code/Chapter 11/Do Upload.php: -------------------------------------------------------------------------------- 1 | load->helper(array('form', 'url')); 10 | $this->load->library('upload'); 11 | } 12 | 13 | /*now the function which does all the work!*/ 14 | 15 | function do_upload() 16 | { 17 | 18 | if ( ! $this->upload->do_upload()) 19 | { 20 | $error = array('error' => $this->upload->display_errors()); 21 | 22 | $this->load->view('upload_form', $error); 23 | } 24 | else 25 | { 26 | $data = array('upload_data' => $this->upload->data()); 27 | 28 | $this->load->view('upload_success', $data); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /code/Chapter 12/Function Report me.txt: -------------------------------------------------------------------------------- 1 | function reportme($file, $line, $message) 2 | { 3 | $obj =& get_instance(); 4 | if(isset($_POST)) 5 | {$bert = print_r($_POST, TRUE);} 6 | else {$bert = 'no post array';} 7 | if(isset($_SESSION)) 8 | {$sid = print_r($_SESSION, TRUE);} 9 | else{$sid = 'no session array';} 10 | 11 | $time = Gmdate("H:i j-M-Y"); 12 | /*full report*/ 13 | $errorstring = "$time - $file - $line: $message: POST array: $bert SESSION array: $sid\n"; 14 | 15 | /*short report*/ 16 | $shortstring = "$file - $line: $message"; 17 | 18 | /*set $setting to 'test' if you want to write to the screen*/ 19 | $setting = 'test'; 20 | if($setting == 'test') 21 | {echo $errorstring;} 22 | 23 | /*set $action to 'log' if you want to log errors*/ 24 | $action = 'log'; 25 | if($action == 'log') 26 | { 27 | $filename = $obj->config->item('errorfile'); 28 | $fp = fopen("$filename", "a+")or die("cant open file"); 29 | fwrite($fp, $errorstring); 30 | fclose($fp); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /code/Chapter 13/Controller_for_sites_table.php: -------------------------------------------------------------------------------- 1 | load->model('crud'); 12 | } 13 | 14 | /*function to update an entry (if an ID is sent) or to insert a new one. Also includes validation, courtesy of CI */ 15 | function insert($id) 16 | { 17 | $this->crud->insert($this->controller, $id); 18 | } 19 | 20 | /*interim function to pass post data from an update or insert through to Crud model, which can't receive it directly*/ 21 | function interim() 22 | { 23 | $this->crud->insert2($this->controller, $_POST); 24 | } 25 | 26 | /*function to delete an entry, needs table name and id. If called directly, needs parameters passed to function; if not, from Post array*/ 27 | function delete($idno=0, $state='no') 28 | { 29 | if(isset($_POST['id'])&& $_POST['id'] > 0) 30 | {$idno = $_POST['id'];} 31 | if(isset($_POST['submit'])) 32 | {$state = $_POST['submit'];} 33 | $this->crud->delete($this->controller, $idno, $state); 34 | } 35 | 36 | /*function to show all entries for a table*/ 37 | function showall() 38 | { 39 | $this->crud->showall($this->controller, $message); 40 | } 41 | 42 | 43 | /*function to show all data in a table, but doesn't allow any alterations*/ 44 | function read() 45 | { 46 | $this->crud->read($this->controller); 47 | } 48 | 49 | /*function to set off the test suite on the 'crud' model. This function need only appear in one controller, as these tests are made on a temporary test table so that your real data is not affected*/ 50 | function test() 51 | { 52 | $this->crud->test(); 53 | } 54 | } 55 | ?> 56 | -------------------------------------------------------------------------------- /code/Chapter 13/delete_function.txt: -------------------------------------------------------------------------------- 1 | /*DELETE FUNCTION: given table name and id number, deletes an entry*/ 2 | function delete($controller, $idno, $state='no', $test='no') 3 | { 4 | /*first check that the 'yes' flag is set. If not, go through the trydelete function to give them a chance to change their minds*/ 5 | if(!isset($state) || $state != 'yes') 6 | { 7 | /*test block: are 'yes' flags recognised?*/ 8 | if($test == 'yes') 9 | { 10 | $place = __FILE__.__LINE__; 11 | $outcome = "exception at $place: sent state value $state to trydelete function "; 12 | return $outcome; 13 | } 14 | else 15 | /*end test block*/ 16 | {$this->trydelete($controller, $idno, 'no');} 17 | } 18 | else{ 19 | /*'yes' flag is set, so now make sure there is an id number*/ 20 | if(isset($idno) && $idno > 0 && is_int($idno)) 21 | /*test block: with this id no, am I going to do a delete?*/ 22 | { 23 | if($test == 'yes') 24 | { 25 | $place = __FILE__.__LINE__; 26 | $outcome = "OK at $place: doing delete on id of $idno "; 27 | return $outcome; 28 | } 29 | else{ 30 | /*end test block*/ 31 | /*if there is an id number, do the delete*/ 32 | 33 | $this->db->where('id', $idno); 34 | $this->db->delete($controller); 35 | $changes = $this->db->affected_rows(); 36 | } 37 | 38 | if($changes != 1) 39 | { 40 | /*test block: did I actually do a delete? */ 41 | $place = __FILE__.__LINE__; 42 | $outcome = "exception at $place: cdnt do delete op on $controller with id no of $idno"; 43 | if($test == 'yes') 44 | {return $outcome;} 45 | else 46 | /*end test block*/ 47 | /*if there was no update, report it*/ 48 | {$this->failure($outcome);} 49 | } 50 | else{ 51 | /*test block: I did do a delete*/ 52 | if($test == 'yes') 53 | {return 'OK';} 54 | else{ 55 | /*end test block: report the delete*/ 56 | $this->showall($controller, "Entry no. $idno deleted.");} 57 | } 58 | } 59 | else 60 | /*test block: report id number wasn't acceptable'*/ 61 | { 62 | $place = __FILE__.__LINE__; 63 | $outcome = "exception at: $place : id no of $idno set for delete op in $controller, expecting integer"; 64 | 65 | if($test == 'yes') 66 | {return $outcome;} 67 | else 68 | /*endtest block: if I failed, report me*/ 69 | {$this->failure($outcome);} 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /code/Chapter 13/insert2_function.txt: -------------------------------------------------------------------------------- 1 | function insert2($controller, $newpost, $test = 'no') 2 | { 3 | $myform = ''; 4 | 5 | /*test the incoming parameters*/ 6 | if(!$this->db->table_exists($controller)) 7 | { 8 | //test here! 9 | } 10 | 11 | $this->load->library('validation'); 12 | 13 | /*handle the validation. Note that the validation class works from the post array, whereas this function only has a $newpost array: same data, but different name. So we re-created the $_POST array. 14 | */ 15 | $_POST = $newpost; 16 | 17 | /*now build up the validation rules from the entries in our master array*/ 18 | $errorform = ''; 19 | $newtemparray = $this->form[$controller]; 20 | foreach($newtemparray as $key => $value) 21 | {$rules[$key]= $value[2];} 22 | $this->validation->set_rules($rules); 23 | 24 | /*and the name fields*/ 25 | foreach($newtemparray as $key => $value) 26 | {$fields[$key]= $value[0];} 27 | $this->validation->set_fields($fields); 28 | 29 | 30 | 31 | $this->validation->set_fields($fields); 32 | 33 | /*now do the validation run*/ 34 | if ($this->validation->run() == FALSE) 35 | { 36 | /*if the validation run fails, re-present the entry form by calling the 'insert' function*/ 37 | $id = $_POST['id']; 38 | $this->insert($controller, $id, 'no', $_POST); 39 | 40 | } 41 | else 42 | { 43 | /*The validation check was OK so we carry on. Check if there is an id number*/ 44 | if(isset($_POST['id']) && $_POST['id'] > 0) 45 | { 46 | /*if yes: this is an update, so you don't want the id number in the post array because it will confuse the autoincrement id field in the database. Remove it, but save it in $tempid to use in the 'where' condition of the update query, then do the update*/ 47 | $tempid = $_POST['id']; 48 | unset($_POST['id']); 49 | $this->db->where('id', $tempid); 50 | $this->db->update($controller, $_POST); 51 | if($this->db->affected_rows()== 1) 52 | {$this->showall($controller, "Entry number $tempid updated.");} 53 | else{$this->failure("Failed to update $controller for id no $tempid", __FILE__,__LINE__);} 54 | 55 | /*if no id number, we assume this is a new entry: no need to unset the post array id as it isn't there! the database will create its own id number. Do the new entry*/ 56 | $this->db->insert($controller, $_POST); 57 | if($this->db->affected_rows()== 1) 58 | {$this->showall($controller, "New entry added.");} 59 | else{$this->failure("Failed to make new entry in $controller ", __FILE__,__LINE__);} 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /code/Chapter 13/insert_function.txt: -------------------------------------------------------------------------------- 1 | /*the most complex function. This creates an HTML form, based on the description of the fields in the form array. This is sent to our display model, which sets up a view and shows it to the user. 2 | The view then sends a POST array back to the controller. The form can't call this model directly, so it has to call the controller, which refers it back to the model. 3 | Note the function parameters: 4 | 1. The controller parameter is whichever controller/ table has called the model - eg the 'sites' controller, or the 'domains' controller. The controller has the same name as the table it manipulates. 5 | 2. The optional id parameter is the id of an individual entry in that table. 6 | 3. The optional 'test' parameter is so you can set the form up to make usable responses to self-test functions. 7 | */ 8 | 9 | function insert($controller='', $id=0, $test='no') 10 | { 11 | $myform = ''; 12 | $myid = 0; 13 | $currentvalue = array(); 14 | 15 | /*test if the table exists*/ 16 | if(!$this->db->table_exists($controller)) 17 | { 18 | $place = __FILE__.__LINE__; 19 | $outcome = "exception: $place:looking for table $controller: it doesn't exist'"; 20 | if($test =='yes') 21 | { 22 | return $outcome; 23 | } 24 | else{ 25 | $this->failure($outcome, $controller); 26 | } 27 | } 28 | else 29 | { 30 | if($test =='yes') 31 | { 32 | return 'OK'; 33 | } 34 | } 35 | /*end test block*/ 36 | 37 | /*first check if there is an id number. If there is, we need to get the values to populate the table fields*/ 38 | if(isset($id) && $id > 0) 39 | {$myid = $id; 40 | $this->db->where('id', $id); 41 | $query = $this->db->get($controller); 42 | if ($query->num_rows() > 0) 43 | { 44 | $row = $query->row(); 45 | //--------------work out the values we want! 46 | foreach($row as $key =>$value) 47 | /* 48 | first of all work out what value you want to show as the existing value in each line of the form. In priority order these are: 49 | 1. the last value the user entered, from the post array 50 | 2. the value from the database 51 | 3. nothing, if neither of these is set. 52 | if we got here, the id does exist and is returning values, so get the existing values into a value array. Or, if there is something in the validation array, use that instead*/ 53 | { 54 | $_POST[$key] = $this->validation->$key; 55 | if(isset($_POST[$key])) 56 | {$currentvalue[$key] = $_POST[$key];} 57 | else 58 | {$currentvalue[$key] = $value;} 59 | } 60 | 61 | /*test block: there was an id number, so has the programme gone for an update? if this is not a test, of course, just do the update*/ 62 | if($test == 'yes') 63 | { 64 | $place = __FILE__.__LINE__; 65 | $outcome = "exception: $place: id of $id returned results from $controller table so have gone for update"; 66 | return $outcome; 67 | } 68 | 69 | /*end test block*/ 70 | $myform .= "Update existing entry number $id"; 71 | } 72 | /*now catch situation where this id number isn't returning results. In this instance this is an error, since it shdn't have got here with a false ID'.*/ 73 | else{ 74 | $place = __FILE__.__LINE__; 75 | $outcome = "exception: $place: despite id of $id cant get any results from $controller table"; 76 | 77 | if($test == 'yes') 78 | /*test block: there was and ID but there were no results*/ 79 | { 80 | return $outcome; 81 | } 82 | /*end test block*/ 83 | else 84 | {$this->failure($outcome, $controller);} 85 | 86 | } 87 | } 88 | 89 | /*there was no ID number, so this is a new entry*/ 90 | else{ 91 | /*If the user has filled in values, and has returned here because some of them didn't validate, we still need to repopulate the form with what he entered, so he only has to alter the one that didn't validate. Get these from the post array*/ 92 | 93 | if(isset($_POST)) 94 | { 95 | foreach($_POST as $key => $value) 96 | { 97 | if(isset($_POST[$key])) 98 | {$currentvalue[$key] = $_POST[$key];} 99 | } 100 | 101 | } 102 | $myform .= "New entry"; 103 | 104 | /*test block: there was no ID, so this is a new entry*/ 105 | if($test == 'yes') 106 | { 107 | $place = __FILE__.__LINE__; 108 | $outcome = "exception: $place: id of $id treated as no id, so going for new entry"; 109 | return $outcome; 110 | } 111 | /*end test block*/ 112 | } 113 | 114 | 115 | /*the table exists, whether this is an update or new entry, so start to build the form*/ 116 | $myform .= ""; 117 | $myform .= form_open("$controller/interim"); 118 | $myform .= '

This entry could not be made because...

'; 119 | $myform .= $this->validation->error_string; 120 | 121 | 122 | /*the rest of this function is common to inserts or update. 123 | Look up in the form array which form field type you want to display, and then build up the html for each different type, as well as inserting the values you want it to echo.*/ 124 | 125 | 126 | 127 | foreach($this->form[$controller] as $key => $value) 128 | { 129 | 130 | /*This switch statement develops several types of HTML form field based on information in the form array. 131 | It doesn't yet cover checkboxes or radio or password fields. It adds a 'readonly' type, which is a field that only displays a value and doesn't let the user modify it*/ 132 | 133 | $fieldtype = $value[1]; 134 | $val_string = $this->validation->$key; 135 | switch($value[1]) 136 | { 137 | /*a simple input line*/ 138 | case 'input': 139 | $data = array( 140 | 'name' => $key, 141 | 'id' => $key, 142 | 'value' => $currentvalue[$key], 143 | 'maxlength' => '100', 144 | 'size' => '50', 145 | 'style' => 'width:50%', 146 | ); 147 | $myform .= ""; 150 | if($test == 'second') 151 | { 152 | return 'input'; 153 | } 154 | break; 155 | 156 | case 'textarea': 157 | /*a text area field.*/ 158 | $data = array( 159 | 'name' => $key, 160 | 'id' => $key, 161 | 'value' => $currentvalue[$key], 162 | 'rows' => '6', 163 | 'cols' => '70', 164 | 'style' => 'width:50%', 165 | ); 166 | $myform .= ""; 169 | break; 170 | 171 | case 'dropdown': 172 | /*a drop down box. Values are dynamically generated from whichever table was specified in the forms array. This table must have an id field (which is now entered in the form) and a name field (which is displayed in the drop-down box).*/ 173 | $dropbox = array(); 174 | if(isset($value[3])) 175 | { 176 | $temptable = $value[3]; 177 | $this->db->select('id, name'); 178 | $query = $this->db->get($temptable); 179 | if ($query->num_rows() > 0) 180 | { 181 | foreach ($query->result() as $row) 182 | { 183 | $dropbox[$row->id] = $row->name; 184 | } 185 | } 186 | } 187 | $myform .= ""; 190 | break; 191 | 192 | case 'submit': 193 | /*a submit field*/ 194 | $myform .= ""; 202 | 203 | break; 204 | 205 | case 'hidden': 206 | /*generates a hidden field*/ 207 | $myform .= form_hidden($key, $currentvalue[$key]); 208 | break; 209 | 210 | case 'readonly': 211 | /*generates a field the user can see, but not alter.*/ 212 | 213 | $myform .= ""; 217 | 218 | break; 219 | 220 | case 'timestamp': 221 | /*generates a timestamp the first time it's set*/ 222 | // $myform .= ""; 231 | 232 | break; 233 | 234 | case 'updatestamp': 235 | /*generates a timestamp each time it's altered or viewed*/ 236 | // $myform .= ""; 240 | 241 | break; 242 | 243 | default: 244 | $place = __FILE__.__LINE__; 245 | $outcome = "exception: $place: switch can't handle $fieldtype"; 246 | /*test block: what if the switch doesn't recognise the form type?'*/ 247 | if($test == 'second') 248 | { 249 | return $outcome; 250 | } 251 | /*test block ends*/ 252 | else { 253 | 254 | $this->failure($outcome, $controller); 255 | } 256 | } 257 | /*end the foreach loop which generates the form*/ 258 | } 259 | $myform .= form_hidden('submit',$time); 260 | $myform .= form_close(); 261 | $myform .= "
$value[0]"; 148 | $myform .= form_input($data); 149 | $myform .= "
$value[0]"; 167 | $myform .= form_textarea($data); 168 | $myform .= "
$value[0]"; 188 | $myform .= form_dropdown($key, $dropbox, $currentvalue[$key]); 189 | $myform .= "
$value[0]"; 195 | $time = time(); 196 | $data = array( 197 | 'name' => 'submit', 198 | 'id' => 'submit', 199 | ); 200 | $myform .= form_submit($data); 201 | $myform .= "
$value[0]$currentvalue[$key]"; 214 | 215 | $myform .= form_hidden($key, $currentvalue[$key]); 216 | $myform .= "
$value[0]now()"; 223 | $timenow = time(); 224 | 225 | if($currentvalue[$key]==''||$currentvalue[$key]==0) 226 | {$time = $timenow;} 227 | else{$time = $currentvalue[$key];} 228 | 229 | $myform .= form_hidden($key, $time); 230 | $myform .= "
$value[0]now()"; 237 | $timenow = time(); 238 | $myform .= form_hidden($key, $timenow); 239 | $myform .= "
"; 262 | 263 | /*Finally we've built our form and populated it! Now, stuff the form in an array variable and send it to the model which builds up the rest of the view.*/ 264 | $data['text'] = $myform; 265 | $this->display->mainpage($data); 266 | } 267 | -------------------------------------------------------------------------------- /code/Chapter 13/showall_function.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/code/Chapter 13/showall_function.txt -------------------------------------------------------------------------------- /code/Chapter 13/test_function.txt: -------------------------------------------------------------------------------- 1 | /*now a suite of self-test functions.*/ 2 | 3 | /*first function just calls all the others and supplies any formatting you want. Also it builds/ destroys temporary data table before/ after tests on the database.*/ 4 | function test() 5 | { 6 | $return = "

Test results

"; 7 | $this->extendarray(); 8 | $return .= $this->testarray(); 9 | $this->reducearray(); 10 | $return .= $this->testarray(); 11 | $this->testbuild(); 12 | $return .= $this->testdelete(); 13 | $this->testdestroy(); 14 | $return .= $this->testinsert(); 15 | $return .= $this->testinsert2(); 16 | $return .= $this->testshowall(); 17 | $data['text'] = $return; 18 | $this->display->mainpage($data); 19 | } 20 | -------------------------------------------------------------------------------- /code/Chapter 13/trydelete_function.txt: -------------------------------------------------------------------------------- 1 | /*TRYDELETE FUNCION: interrupts deletes with an 'are you sure? screen'*/ 2 | function trydelete($controller, $idno, $submit = 'no') 3 | { 4 | if($state == 'yes') 5 | {$this->delete($controller, $idno, 'yes');} 6 | else{ 7 | $result .= ""; 8 | $result .= form_open("$controller/delete"); 9 | $result .= form_hidden('id', $idno); 10 | $result .= ""; 13 | $result .= form_close(); 14 | $result .= "
Are you sure you want to delete this entry?
"; 11 | $result .= form_submit('submit', 'yes'); 12 | $result .= "
"; 15 | $result .= anchor("$controller/showall","No, don't delete"); 16 | $data['text'] = $result; 17 | $this->display->mainpage($data); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /code/Chapter 14/Function to run an individual test.txt: -------------------------------------------------------------------------------- 1 | /*function to run an individual test*/ 2 | function runtest($testid, $user='human') 3 | { 4 | // echo "run test $testid"; 5 | /*first, look up the test details */ 6 | $this->db->where('id', $testid); 7 | $query = $this->db->get('tests'); 8 | if ($query->num_rows() > 0) 9 | { 10 | foreach ($query->result() as $row) 11 | { 12 | $type = $row->type; 13 | /*then work out which type it is and forward it accordingly*/ 14 | switch ($type){ 15 | case 'ping': 16 | $this->benchmark->mark('code_start'); 17 | $result =$this->pingtest($testid); 18 | $this->benchmark->mark('code_end'); 19 | $timetaken = $this->benchmark->elapsed_time('code_start', 'code_end'); 20 | break; 21 | 22 | 23 | case 'ete' : 24 | $this->benchmark->mark('code_start'); 25 | $result = $this->httppost($testid); 26 | $this->benchmark->mark('code_end'); 27 | $timetaken = $this->benchmark->elapsed_time('code_start', 'code_end'); 28 | break; 29 | 30 | default: 31 | $result = 'noid'; 32 | } 33 | 34 | /*work out which site the test belongs to*/ 35 | $this->db->select('tests.siteid AS id'); 36 | $this->db->where('id', $testid); 37 | $query = $this->db->get('tests'); 38 | if ($query->num_rows() > 0) 39 | {$srow = $query->row(); 40 | $mysiteid = $srow->id; 41 | } 42 | else{$mysiteid = 0;} 43 | 44 | /*build the rest of the result set and enter it into the database*/ 45 | $time = now(); 46 | 47 | if($result == 'OK') 48 | {$isalert = 'n';} 49 | else{$isalert = 'y';} 50 | 51 | $this->db->set('name', $type); 52 | $this->db->set('type', 'test'); 53 | $this->db->set('timetaken', $timetaken); 54 | if($result != '') 55 | {$this->db->set('result', $result);} 56 | $this->db->set('testid', $testid); 57 | $this->db->set('userid', 0); 58 | $this->db->set('siteid', $mysiteid); 59 | $this->db->set('time', $time); 60 | 61 | $this->db->set('isalert', $isalert); 62 | $this->db->insert('events'); 63 | 64 | $mydata = array( 65 | 'lastdone' => $time, 66 | 'notes' => $result, 67 | 'isalert' => $isalert 68 | ); 69 | $this->db->where('id', $testid); 70 | $this->db->update('tests', $mydata); 71 | 72 | /*only return this info to screen if user is human. Otherwise, no need to do anything more; you've updated the database.*/ 73 | if($user == 'human') 74 | {$mytext = ""; 75 | $mytext .= ""; 76 | $mytext .= "
Test took $timetaken.Result was ".$result.'
'; 77 | $mytext .= $this->testhistory($testid); 78 | $response['mytext'] = $mytext; 79 | $this->display->mainpage($response);} 80 | else{return $response;} 81 | } 82 | } 83 | } 84 | 85 | -------------------------------------------------------------------------------- /code/Chapter 4/Query to set up 'websites' database.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE IF EXISTS `ci_sessions`; 2 | CREATE TABLE IF NOT EXISTS `ci_sessions` ( 3 | `session_id` varchar(40) NOT NULL default '0', 4 | `peopleid` int(11) NOT NULL, 5 | `ip_address` varchar(16) NOT NULL default '0', 6 | `user_agent` varchar(50) NOT NULL, 7 | `last_activity` int(10) unsigned NOT NULL default '0', 8 | `left` int(11) NOT NULL, 9 | `name` varchar(25) NOT NULL, 10 | `status` tinyint(4) NOT NULL default '0' 11 | ) ENGINE=MyISAM DEFAULT CHARSET=latin1; 12 | 13 | DROP TABLE IF EXISTS `domains`; 14 | CREATE TABLE IF NOT EXISTS `domains` ( 15 | `id` int(10) NOT NULL auto_increment, 16 | `url` varchar(100) NOT NULL, 17 | `name` varchar(100) NOT NULL, 18 | `registrar` varchar(100) NOT NULL, 19 | `dateregd` int(11) NOT NULL default '0', 20 | `cost` float NOT NULL default '0', 21 | `regdfor` int(11) NOT NULL default '0', 22 | `notes` blob NOT NULL, 23 | `pw` varchar(25) NOT NULL, 24 | `un` varchar(25) NOT NULL, 25 | `lastupdate` int(11) NOT NULL default '0', 26 | `submit` varchar(25) NOT NULL, 27 | PRIMARY KEY (`id`) 28 | ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=10 ; 29 | 30 | DROP TABLE IF EXISTS `events`; 31 | CREATE TABLE IF NOT EXISTS `events` ( 32 | `id` int(10) NOT NULL auto_increment, 33 | `name` varchar(50) NOT NULL default 'not set', 34 | `type` enum('test','alert','report') NOT NULL, 35 | `testid` int(10) NOT NULL, 36 | `siteid` int(10) NOT NULL, 37 | `userid` int(10) NOT NULL, 38 | `reported` int(11) NOT NULL, 39 | `result` blob NOT NULL, 40 | `time` int(11) NOT NULL, 41 | `timetaken` float NOT NULL, 42 | `isalert` varchar(2) NOT NULL, 43 | `emailid` int(11) NOT NULL, 44 | `submit` varchar(25) NOT NULL, 45 | PRIMARY KEY (`id`) 46 | ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=69 ; 47 | 48 | DROP TABLE IF EXISTS `frequencies`; 49 | CREATE TABLE IF NOT EXISTS `frequencies` ( 50 | `id` int(10) NOT NULL, 51 | `name` varchar(16) NOT NULL, 52 | `submit` varchar(25) NOT NULL, 53 | PRIMARY KEY (`id`) 54 | ) ENGINE=MyISAM DEFAULT CHARSET=latin1; 55 | 56 | DROP TABLE IF EXISTS `hosts`; 57 | CREATE TABLE IF NOT EXISTS `hosts` ( 58 | `id` int(11) NOT NULL auto_increment, 59 | `cost` float NOT NULL, 60 | `name` varchar(100) NOT NULL, 61 | `hosturl` varchar(100) NOT NULL, 62 | `un` varchar(50) NOT NULL, 63 | `pw` varchar(50) NOT NULL, 64 | `ns1url` varchar(36) NOT NULL, 65 | `ns1ip` varchar(36) NOT NULL, 66 | `ns2url` varchar(36) NOT NULL, 67 | `ns2ip` varchar(36) NOT NULL, 68 | `ftpurl` varchar(100) NOT NULL, 69 | `ftpserverip` varchar(36) NOT NULL, 70 | `ftpun` varchar(50) NOT NULL, 71 | `ftppw` varchar(50) NOT NULL, 72 | `cpurl` varchar(36) NOT NULL, 73 | `cpun` varchar(36) NOT NULL, 74 | `cppw` varchar(36) NOT NULL, 75 | `pop3server` varchar(36) NOT NULL, 76 | `servicetel` varchar(50) NOT NULL, 77 | `servicetel2` varchar(50) NOT NULL, 78 | `serviceemail` varchar(100) NOT NULL, 79 | `webroot` varchar(48) NOT NULL, 80 | `absoluteroot` varchar(48) NOT NULL, 81 | `cgiroot` varchar(48) NOT NULL, 82 | `booked` int(11) NOT NULL, 83 | `duration` int(11) NOT NULL, 84 | `lastupdate` int(11) NOT NULL default '0', 85 | `submit` varchar(25) NOT NULL, 86 | PRIMARY KEY (`id`) 87 | ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ; 88 | 89 | DROP TABLE IF EXISTS `people`; 90 | CREATE TABLE IF NOT EXISTS `people` ( 91 | `id` int(11) NOT NULL auto_increment, 92 | `uname` varchar(25) NOT NULL, 93 | `pw` varchar(25) NOT NULL, 94 | `status` smallint(3) NOT NULL default '1', 95 | `name` varchar(50) NOT NULL, 96 | `firstname` varchar(50) NOT NULL, 97 | `surname` varchar(50) NOT NULL, 98 | `email` varchar(120) NOT NULL, 99 | `lastupdate` int(11) NOT NULL default '0', 100 | `submit` varchar(25) NOT NULL, 101 | PRIMARY KEY (`id`) 102 | ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ; 103 | 104 | DROP TABLE IF EXISTS `sites`; 105 | CREATE TABLE IF NOT EXISTS `sites` ( 106 | `id` int(10) NOT NULL auto_increment, 107 | `name` varchar(100) NOT NULL, 108 | `url` varchar(100) NOT NULL, 109 | `un` varchar(50) NOT NULL, 110 | `pw` varchar(50) NOT NULL, 111 | `client1` int(10) NOT NULL default '0', 112 | `client2` int(10) NOT NULL default '0', 113 | `admin1` int(10) NOT NULL default '0', 114 | `admin2` int(10) NOT NULL default '0', 115 | `domainid` int(10) NOT NULL default '0', 116 | `hostid` int(10) NOT NULL default '0', 117 | `webroot` varchar(50) NOT NULL, 118 | `files` text NOT NULL, 119 | `filesdate` int(11) NOT NULL default '0', 120 | `lastupdate` int(11) NOT NULL default '0', 121 | `submit` varchar(25) NOT NULL, 122 | PRIMARY KEY (`id`) 123 | ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=15 ; 124 | 125 | DROP TABLE IF EXISTS `tests`; 126 | CREATE TABLE IF NOT EXISTS `tests` ( 127 | `id` int(11) NOT NULL auto_increment, 128 | `siteid` int(11) NOT NULL default '0', 129 | `name` varchar(250) NOT NULL, 130 | `type` varchar(25) NOT NULL, 131 | `url` varchar(120) NOT NULL, 132 | `regex` varchar(250) NOT NULL, 133 | `p1` varchar(250) NOT NULL, 134 | `p2` varchar(250) NOT NULL, 135 | `p3` varchar(250) NOT NULL, 136 | `p4` varchar(250) NOT NULL, 137 | `p5` varchar(250) NOT NULL, 138 | `p6` varchar(250) NOT NULL, 139 | `frequency` int(10) NOT NULL default '0', 140 | `lastdone` int(10) NOT NULL default '0', 141 | `isalert` varchar(2) NOT NULL, 142 | `setup` int(10) NOT NULL default '0', 143 | `lastupdate` int(10) NOT NULL default '0', 144 | `notes` varchar(250) NOT NULL, 145 | `submit` varchar(25) NOT NULL, 146 | PRIMARY KEY (`id`) 147 | ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=11 ; 148 | 149 | DROP TABLE IF EXISTS `types`; 150 | CREATE TABLE IF NOT EXISTS `types` ( 151 | `id` varchar(7) NOT NULL, 152 | `name` varchar(50) NOT NULL, 153 | PRIMARY KEY (`id`) 154 | ) ENGINE=MyISAM DEFAULT CHARSET=latin1; 155 | -------------------------------------------------------------------------------- /code/Chapter 5/My Display Model.php: -------------------------------------------------------------------------------- 1 | load->helper('form'); 16 | $this->load->library('user_agent'); 17 | $this->load->library('session'); 18 | 19 | /*now set the standard parts of the array*/ 20 | $this->data['css'] = $this->config->item('css'); 21 | $this->data['base'] = $this->config->item('base_url'); 22 | $this->base = $this->config->item('base_url'); 23 | $this->data['myrobots'] = ''; 24 | /*note that CI's session stuff doesn't automatically recall the extra variables you have added, so you have to look up the user's status in the ci_sessions table*/ 25 | $sessionid = $this->session->userdata('session_id'); 26 | $this->db->select('status'); 27 | $this->db->where('session_id', $sessionid); 28 | $query = $this->db->get('ci_sessions'); 29 | if ($query->num_rows() > 0) 30 | { 31 | $row = $query->row(); 32 | $this->status = $row->status; 33 | } 34 | 35 | } 36 | 37 | /*function to assemble a standard page. Any controller can call this. Just supply as $mydata an array, of key/value pairs for the contents you want the view to display. Available variables in this view are: 38 | mytitle. menu, mytext, diagnostic 39 | */ 40 | function mainpage($mydata) 41 | { 42 | $this->data['mytitle'] = 'Monitoring website'; 43 | $this->data['diagnostic'] = $diagnostic; 44 | foreach($mydata as $key => $variable) 45 | { 46 | $this->data[$key] = $variable; 47 | } 48 | 49 | $this->load->library('session'); 50 | $mysess = $this->session->userdata('session_id'); 51 | if (isset($this->status) && $this->status > 0) 52 | { 53 | $this->data['menu']= $this->status; 54 | } 55 | $this->load->view('basic_view', $this->data); 56 | } 57 | } -------------------------------------------------------------------------------- /credits.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/credits.html -------------------------------------------------------------------------------- /credits_cn.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/credits_cn.html -------------------------------------------------------------------------------- /css/main.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/css/main.css -------------------------------------------------------------------------------- /images/13.5.1.1_1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/images/13.5.1.1_1.gif -------------------------------------------------------------------------------- /images/13.5.1.2_1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/images/13.5.1.2_1.gif -------------------------------------------------------------------------------- /images/3.2_1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/images/3.2_1.jpg -------------------------------------------------------------------------------- /images/3.8.4_1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/images/3.8.4_1.gif -------------------------------------------------------------------------------- /images/7.1.1_1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/images/7.1.1_1.gif -------------------------------------------------------------------------------- /images/7.1.1_2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/images/7.1.1_2.gif -------------------------------------------------------------------------------- /images/7.1.1_3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/images/7.1.1_3.gif -------------------------------------------------------------------------------- /images/7.1.1_4.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/images/7.1.1_4.gif -------------------------------------------------------------------------------- /images/7.2_1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/images/7.2_1.gif -------------------------------------------------------------------------------- /images/CodeIgniter-03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/images/CodeIgniter-03.png -------------------------------------------------------------------------------- /images/CodeIgniter-05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/images/CodeIgniter-05.png -------------------------------------------------------------------------------- /images/CodeIgniter-06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/images/CodeIgniter-06.png -------------------------------------------------------------------------------- /images/CodeIgniter-08.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/images/CodeIgniter-08.gif -------------------------------------------------------------------------------- /images/CodeIgniter-09.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/images/CodeIgniter-09.gif -------------------------------------------------------------------------------- /images/CodeIgniter-10.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/images/CodeIgniter-10.gif -------------------------------------------------------------------------------- /images/CodeIgniter-11.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/images/CodeIgniter-11.gif -------------------------------------------------------------------------------- /images/CodeIgniter-12.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/images/CodeIgniter-12.gif -------------------------------------------------------------------------------- /images/CodeIgniter-13.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/images/CodeIgniter-13.gif -------------------------------------------------------------------------------- /images/CodeIgniter-14.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/images/CodeIgniter-14.gif -------------------------------------------------------------------------------- /images/CodeIgniter-15.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/images/CodeIgniter-15.gif -------------------------------------------------------------------------------- /images/CodeIgniter-16.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/images/CodeIgniter-16.gif -------------------------------------------------------------------------------- /images/CodeIgniter-17.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/images/CodeIgniter-17.gif -------------------------------------------------------------------------------- /images/CodeIgniter-18.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/images/CodeIgniter-18.gif -------------------------------------------------------------------------------- /images/CodeIgniter-19.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/images/CodeIgniter-19.gif -------------------------------------------------------------------------------- /images/CodeIgniter-20.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/images/CodeIgniter-20.gif -------------------------------------------------------------------------------- /images/CodeIgniter-21.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/images/CodeIgniter-21.jpg -------------------------------------------------------------------------------- /images/CodeIgniter-22.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/images/CodeIgniter-22.jpg -------------------------------------------------------------------------------- /images/CodeIgniter-23.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/images/CodeIgniter-23.jpg -------------------------------------------------------------------------------- /images/CodeIgniter-24.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/images/CodeIgniter-24.gif -------------------------------------------------------------------------------- /images/CodeIgniter-25.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/images/CodeIgniter-25.gif -------------------------------------------------------------------------------- /images/CodeIgniter-26.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/images/CodeIgniter-26.gif -------------------------------------------------------------------------------- /images/CodeIgniter-27.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/images/CodeIgniter-27.gif -------------------------------------------------------------------------------- /images/CodeIgniter-28.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/images/CodeIgniter-28.gif -------------------------------------------------------------------------------- /images/CodeIgniter-29.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/images/CodeIgniter-29.gif -------------------------------------------------------------------------------- /images/CodeIgniter-30.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/images/CodeIgniter-30.gif -------------------------------------------------------------------------------- /images/CodeIgniter-31.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/images/CodeIgniter-31.gif -------------------------------------------------------------------------------- /images/CodeIgniter-32.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/images/CodeIgniter-32.gif -------------------------------------------------------------------------------- /images/CodeIgniter-33.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/images/CodeIgniter-33.gif -------------------------------------------------------------------------------- /images/CodeIgniter-34.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/images/CodeIgniter-34.gif -------------------------------------------------------------------------------- /images/CodeIgniter-35.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/images/CodeIgniter-35.jpg -------------------------------------------------------------------------------- /images/CodeIgniter-36.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/images/CodeIgniter-36.gif -------------------------------------------------------------------------------- /images/CodeIgniter-37.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/images/CodeIgniter-37.jpg -------------------------------------------------------------------------------- /images/CodeIgniter-38.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/images/CodeIgniter-38.gif -------------------------------------------------------------------------------- /images/CodeIgniter-39.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/images/CodeIgniter-39.gif -------------------------------------------------------------------------------- /images/CodeIgniter-40.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/images/CodeIgniter-40.gif -------------------------------------------------------------------------------- /images/CodeIgniter_02.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/images/CodeIgniter_02.jpg -------------------------------------------------------------------------------- /images/CodeIgniter_07.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/images/CodeIgniter_07.jpg -------------------------------------------------------------------------------- /images/CodeIgniter_cover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/images/CodeIgniter_cover.png -------------------------------------------------------------------------------- /images/copycode.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/images/copycode.gif -------------------------------------------------------------------------------- /images/header.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/images/header.png -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/index.html -------------------------------------------------------------------------------- /js/_main.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/js/_main.js -------------------------------------------------------------------------------- /js/main.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/js/main.js -------------------------------------------------------------------------------- /preface.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/preface.html -------------------------------------------------------------------------------- /preface_cn.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/preface_cn.html -------------------------------------------------------------------------------- /table_of_contents.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodeIgniter-Chinese/rapid-php-application-development/e93cfee90ac42081e54d86e0f6de81341c2d299b/table_of_contents.html --------------------------------------------------------------------------------