Home  >  Article  >  php教程  >  PHP设计模式汇总

PHP设计模式汇总

WBOY
WBOYOriginal
2016-06-21 08:52:57888browse

PHP设计模式:

PHP设计模式之装饰器模式

PHP设计模式之委托模式

PHP设计模式之外观模式

PHP设计模式之工厂模式

PHP设计模式之解释器模式

PHP设计模式之迭代器模式

PHP设计模式之中介者模式

如下为数据库脚本:

<ol class="dp-sql">
<li class="alt"><span><span>/*!40101 </span><span class="keyword">SET</span><span> NAMES utf8 */;   </span></span></li>
<li><span>   </span></li>
<li class="alt"><span>/*!40101 <span class="keyword">SET</span><span> SQL_MODE=</span><span class="string">''</span><span>*/;   </span></span></li>
<li><span>   </span></li>
<li class="alt"><span>/*!40014 <span class="keyword">SET</span><span> @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;   </span></span></li>
<li><span>/*!40014 <span class="keyword">SET</span><span> @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;   </span></span></li>
<li class="alt"><span>/*!40101 <span class="keyword">SET</span><span> @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE=</span><span class="string">'NO_AUTO_VALUE_ON_ZERO'</span><span> */;   </span></span></li>
<li><span>/*!40111 <span class="keyword">SET</span><span> @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;   </span></span></li>
<li class="alt"><span>/*<span class="keyword">Table</span><span> structure </span><span class="keyword">for</span><span> </span><span class="keyword">table</span><span> `cd` */   </span></span></li>
<li><span>   </span></li>
<li class="alt"><span><span class="keyword">DROP</span><span> </span><span class="keyword">TABLE</span><span> IF EXISTS `CD`;   </span></span></li>
<li><span>   </span></li>
<li class="alt"><span><span class="keyword">CREATE</span><span> </span><span class="keyword">TABLE</span><span> `CD` (   </span></span></li>
<li><span>  `id` <span class="keyword">int</span><span>(8) </span><span class="op">NOT</span><span> </span><span class="op">NULL</span><span> AUTO_INCREMENT,   </span></span></li>
<li class="alt"><span>  `band` <span class="keyword">varchar</span><span>(500) </span><span class="keyword">COLLATE</span><span> latin1_bin </span><span class="op">NOT</span><span> </span><span class="op">NULL</span><span> </span><span class="keyword">DEFAULT</span><span> </span><span class="string">''</span><span>,   </span></span></li>
<li><span>  `title` <span class="keyword">varchar</span><span>(500) </span><span class="keyword">COLLATE</span><span> latin1_bin </span><span class="op">NOT</span><span> </span><span class="op">NULL</span><span> </span><span class="keyword">DEFAULT</span><span> </span><span class="string">''</span><span>,   </span></span></li>
<li class="alt"><span>  <span class="keyword">PRIMARY</span><span> </span><span class="keyword">KEY</span><span> (`id`)   </span></span></li>
<li><span>) ENGINE=InnoDB AUTO_INCREMENT=2 <span class="keyword">DEFAULT</span><span> CHARSET=latin1 </span><span class="keyword">COLLATE</span><span>=latin1_bin;   </span></span></li>
<li class="alt"><span>   </span></li>
<li><span>/*Data <span class="keyword">for</span><span> the </span><span class="keyword">table</span><span> `cd` */   </span></span></li>
<li class="alt"><span>   </span></li>
<li><span><span class="keyword">insert</span><span>  </span><span class="keyword">into</span><span> `CD`(`id`,`band`,`title`) </span><span class="keyword">values</span><span> (1,</span><span class="string">'Never Again'</span><span>,</span><span class="string">'Waster of a Rib'</span><span>);   </span></span></li>
<li class="alt"><span>   </span></li>
<li><span>/*<span class="keyword">Table</span><span> structure </span><span class="keyword">for</span><span> </span><span class="keyword">table</span><span> `tracks` */   </span></span></li>
<li class="alt"><span>   </span></li>
<li><span><span class="keyword">DROP</span><span> </span><span class="keyword">TABLE</span><span> IF EXISTS `tracks`;   </span></span></li>
<li class="alt"><span>   </span></li>
<li><span><span class="keyword">CREATE</span><span> </span><span class="keyword">TABLE</span><span> `tracks` (   </span></span></li>
<li class="alt"><span>  `cid` <span class="keyword">int</span><span>(8) </span><span class="keyword">DEFAULT</span><span> </span><span class="op">NULL</span><span>,   </span></span></li>
<li><span>  `tracknum` <span class="keyword">int</span><span>(8) </span><span class="keyword">DEFAULT</span><span> </span><span class="op">NULL</span><span>,   </span></span></li>
<li class="alt"><span>  `title` <span class="keyword">varchar</span><span>(500) </span><span class="keyword">COLLATE</span><span> latin1_bin </span><span class="op">NOT</span><span> </span><span class="op">NULL</span><span> </span><span class="keyword">DEFAULT</span><span> </span><span class="string">''</span><span>   </span></span></li>
<li><span>) ENGINE=InnoDB <span class="keyword">DEFAULT</span><span> CHARSET=latin1 </span><span class="keyword">COLLATE</span><span>=latin1_bin;   </span></span></li>
<li class="alt"><span>   </span></li>
<li><span>/*Data <span class="keyword">for</span><span> the </span><span class="keyword">table</span><span> `tracks` */   </span></span></li>
<li class="alt"><span>   </span></li>
<li><span><span class="keyword">insert</span><span>  </span><span class="keyword">into</span><span> `tracks`(`cid`,`tracknum`,`title`) </span><span class="keyword">values</span><span> (1,3,</span><span class="string">'What It Means'</span><span>),(1,3,</span><span class="string">'Brr'</span><span>),(1,3,</span><span class="string">'Goodbye'</span><span>);   </span></span></li>
<li class="alt"><span>   </span></li>
<li><span>/*!40101 <span class="keyword">SET</span><span> SQL_MODE=@OLD_SQL_MODE */;   </span></span></li>
<li class="alt"><span>/*!40014 <span class="keyword">SET</span><span> FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;   </span></span></li>
<li><span>/*!40014 <span class="keyword">SET</span><span> UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;   </span></span></li>
<li class="alt"><span>/*!40111 <span class="keyword">SET</span><span> SQL_NOTES=@OLD_SQL_NOTES */;   </span></span></li>
</ol>



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn