<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Yaron's Blog &#187; Yaron</title>
	<atom:link href="http://yaron.org.cn/archives/author/admin/feed" rel="self" type="application/rss+xml" />
	<link>http://yaron.org.cn</link>
	<description>About PHP MYSQL JS WEB FreeBSD etc.</description>
	<lastBuildDate>Sat, 31 Jul 2010 13:54:50 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Linux 下的博客离线编辑器 Drivel</title>
		<link>http://yaron.org.cn/archives/208</link>
		<comments>http://yaron.org.cn/archives/208#comments</comments>
		<pubDate>Sat, 31 Jul 2010 13:35:02 +0000</pubDate>
		<dc:creator>Yaron</dc:creator>
				<category><![CDATA[酷软应用]]></category>

		<guid isPermaLink="false">http://yaron.org.cn/?p=208</guid>
		<description><![CDATA[linux 下的博客离线编辑器比较好用的 就算是Drivel了，而且带有草稿功能。很不错

&#60; ?php
phpinfo&#40;&#41;;
?&#62;

]]></description>
			<content:encoded><![CDATA[<p>linux 下的博客离线编辑器比较好用的 就算是Drivel了，而且带有草稿功能。很不错</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span> ?php
<span style="color: #990000;">phpinfo</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://yaron.org.cn/archives/208/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>关于长连接和短连接的区别</title>
		<link>http://yaron.org.cn/archives/207</link>
		<comments>http://yaron.org.cn/archives/207#comments</comments>
		<pubDate>Fri, 14 May 2010 09:17:15 +0000</pubDate>
		<dc:creator>Yaron</dc:creator>
				<category><![CDATA[软件设计]]></category>
		<category><![CDATA[短连接]]></category>
		<category><![CDATA[长连接]]></category>

		<guid isPermaLink="false">http://yaron.org.cn/archives/207</guid>
		<description><![CDATA[&#160;&#160;&#160;&#160; 昨天在某网站测试压力中，首次接触长连接和短连接的概念，记录下来，备忘。
&#160;&#160;&#160; 长连接和短连接的概念出现在移动的CMPP协议中，但是在客户/服务器通信中也有体现。
 


长连接 

在Client 与 Server 建立连接后，持续发送/接收多个报文，报文发送完毕，断开连接。
建立连接后不管当前是否在传输报文都保持连接，安全性较差。
在TCP连接保持期间，如果没有数据包发送，需要双方发检测包以维持此连接。
用于需要长时间连接到服务器的服务（比如CMPP）中，一般需要自己做在线维持。


短连接 

建立连接，发送接收完报文数据后马上断开连接，发送下一个报文时，需要重新建立连接。
只有在有数据传输的时候才进行连接，客户－服务器通信/传输数据完毕就关闭连接。
安全性强，常用于银行系统等安全性较高的环境中。

]]></description>
			<content:encoded><![CDATA[<p>&#160;&#160;&#160;&#160; 昨天在某网站测试压力中，首次接触长连接和短连接的概念，记录下来，备忘。</p>
<p>&#160;&#160;&#160; 长连接和短连接的概念出现在移动的CMPP协议中，但是在客户/服务器通信中也有体现。</p>
<p> <span id="more-207"></span>
</p>
<ul>
<li><strong>长连接</strong> </li>
</ul>
<blockquote><p>在Client 与 Server 建立连接后，持续发送/接收多个报文，报文发送完毕，断开连接。</p>
<p>建立连接后不管当前是否在传输报文都保持连接，安全性较差。</p>
<p>在TCP连接保持期间，如果没有数据包发送，需要双方发检测包以维持此连接。</p>
<p>用于需要长时间连接到服务器的服务（比如CMPP）中，一般需要自己做在线维持。</p>
</blockquote>
<ul>
<li><strong>短连接</strong> </li>
</ul>
<blockquote><p>建立连接，发送接收完报文数据后马上断开连接，发送下一个报文时，需要重新建立连接。</p>
<p>只有在有数据传输的时候才进行连接，客户－服务器通信/传输数据完毕就关闭连接。</p>
<p>安全性强，常用于银行系统等安全性较高的环境中。</p>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://yaron.org.cn/archives/207/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java Servlet + Spring 配置中所遇问题以及处理</title>
		<link>http://yaron.org.cn/archives/195</link>
		<comments>http://yaron.org.cn/archives/195#comments</comments>
		<pubDate>Thu, 08 Apr 2010 09:50:31 +0000</pubDate>
		<dc:creator>Yaron</dc:creator>
				<category><![CDATA[Java开发]]></category>

		<guid isPermaLink="false">http://yaron.org.cn/archives/195</guid>
		<description><![CDATA[项目中需要使用Servlet和Spring，第一次弄这些东西，真是问题重重，把几个主要的问题记录下来，以备后用。
 

错误 1. 
严重: Error configuring application listener of class org.springframework.web.context.ContextLoaderListener      java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
将spring.jar 考到Apache Software<a href="http://yaron.org.cn/archives/195" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[<p>项目中需要使用Servlet和Spring，第一次弄这些东西，真是问题重重，把几个主要的问题记录下来，以备后用。</p>
<p> <span id="more-195"></span>
</p>
<p><strong>错误 1.</strong> </p>
<p><font color="#ff0000">严重: Error configuring application listener of class org.springframework.web.context.ContextLoaderListener      <br />java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener</font></p>
<p>将spring.jar 考到Apache Software Foundation\Tomcat 6.0\lib目录中。    <br /><strong>原理：</strong>     <br />在Web.xml中引入org.springframework.web.context.ContextLoaderListener，启动Tomcat时，尚未引入该类，所以报错。     <br />放入Tomcat的lib目录中，让Tomcat启动时就加载该类。</p>
<p><strong>错误 2.</strong> </p>
<p><font color="#ff0000">严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener      <br />java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory</font></p>
<p>将commons-logging-1.1.1.jar，考到Apache Software Foundation\Tomcat 6.0\lib目录中。</p>
<p><strong>错误 3.</strong></p>
<p><font color="#ff0000">严重: Context initialization failed      <br />org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.hylink.Chinese] for bean with name &#8216;Chinese&#8217; defined in ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.lang.ClassNotFoundException: com.hylink.Chinese</font></p>
<p>这个是Eclipse 编译路径 造成的，默认的是在build/classes目录中，但是Spring只认识WebContent/WEB-INF/classes目录。故：在WebContent/WEB-INF/中创建classes目录，并在Java Build Path &#8211;&gt; Source &#8211;&gt; Default output folder 中设置编译路径为WebContent/WEB-INF/classes</p>
<p>——————————————————&lt; END &gt;————————————————————————</p>
<p>&#160;</p>
<p><strong><font color="#800080" size="4">另外，学习中看到了一些资源，对做这件事帮助很大，记录如下：</font></strong></p>
<p>Spring的安装    <br /><a href="http://blog.csdn.net/arielxp/archive/2005/03/02/308272.aspx">http://blog.csdn.net/arielxp/archive/2005/03/02/308272.aspx</a></p>
<p>Spring在Web项目的布置    <br /><a href="http://book.51cto.com/art/200808/86776.htm">http://book.51cto.com/art/200808/86776.htm</a></p>
<p>Spring的简单入门教程    <br /><a href="http://dev.csdn.net/author/glchengang/1215c7c6f2d440e59df24cb10940b606.html">http://dev.csdn.net/author/glchengang/1215c7c6f2d440e59df24cb10940b606.html</a></p>
<p>在Servlet中注入Spring容器    <br />http://hhlux.javaeye.com/blog/492435</p>
]]></content:encoded>
			<wfw:commentRss>http://yaron.org.cn/archives/195/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL Server 2005用户管理 以及PHP 连接SQL Server 2005 遇到的问题</title>
		<link>http://yaron.org.cn/archives/193</link>
		<comments>http://yaron.org.cn/archives/193#comments</comments>
		<pubDate>Wed, 07 Apr 2010 11:15:50 +0000</pubDate>
		<dc:creator>Yaron</dc:creator>
				<category><![CDATA[PHP功能类库]]></category>

		<guid isPermaLink="false">http://yaron.org.cn/archives/193</guid>
		<description><![CDATA[1.&#160; SQL Server 2005 添加用户时，报错：此版本的 Microsoft Windows 不支持 MUST_CHANGE 选项。(Microsoft SQL Server, Error: 15195)。 
 

解决方案：只需创建登录时取消强制密码过期选项。

&#160;
2.&#160; 使用客户端来连接SQL Server 2005 时，报错：用户<a href="http://yaron.org.cn/archives/193" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[<p><strong>1.&#160; SQL Server 2005 添加用户时，报错：<font color="#ff0000">此版本的 Microsoft Windows 不支持 MUST_CHANGE 选项。(Microsoft SQL Server, Error: 15195)。</font></strong> </p>
<p> <span id="more-193"></span>
</p>
<p>解决方案：<font color="#000080"><strong>只需创建登录时取消强制密码过期选项。</strong></font></p>
<p><strong><font color="#000080"></font></strong></p>
<p>&#160;</p>
<p><strong>2.&#160; 使用客户端来连接SQL Server 2005 时，报错：<font color="#ff0000">用户 &#8216;hylink&#8217; 登录失败。该用户与可信 SQL Server 连接无关联。 (Microsoft SQL Server, Error: 18452)</font></strong></p>
<p><strong><font color="#ff0000"></font></strong></p>
<p>报错原因：<font color="#000080"><strong>该错误产生的原因是由于SQL Server使用了&quot;仅 Windows&quot;的身份验证方式，因此用户无法使用SQL Server的登录帐户（例如 sa )进行连接。</strong></font></p>
<p><strong><font color="#000080"></font></strong></p>
<p>解决方案：<font color="#000080"><strong>数据库身份验证选择&quot;SQL Server和 Windows&quot;方式。</strong></font></p>
<p><strong><font color="#000080"></font></strong></p>
<p><strong><font color="#000080"></font></strong></p>
<p><strong><font color="#000000">3. PHP 连接SQL Server 2005 报错：</font><font color="#000080">Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server</font></strong></p>
<p><strong><font color="#000080"></font></strong></p>
<p>如果PHP.ini设置等都没有问题，那就是ntwdblib.dll 的版本不匹配了，下载正确版本的 ntwdblib.dll (2000.80.194.0)，<a href="http://webzila.com/?wz=dll">http://webzila.com/?wz=dll</a>在这儿找。然后替换apache/bin/和PHP/目录中的netwdblib.dll</p>
]]></content:encoded>
			<wfw:commentRss>http://yaron.org.cn/archives/193/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP/MySQL 基础知识集锦一</title>
		<link>http://yaron.org.cn/archives/179</link>
		<comments>http://yaron.org.cn/archives/179#comments</comments>
		<pubDate>Wed, 16 Dec 2009 08:17:00 +0000</pubDate>
		<dc:creator>Yaron</dc:creator>
				<category><![CDATA[MySQL基础知识]]></category>
		<category><![CDATA[PDT应用]]></category>
		<category><![CDATA[PHP编程基础知识]]></category>

		<guid isPermaLink="false">http://yaron.org.cn/archives/179</guid>
		<description><![CDATA[1&#160; MySQL中把null值转换为0的函数？




1&#160; 
select&#160;ifnull(null,0);



2&#160; PHP 过滤Win系统文件名中的非法字符
 





1&#160; 
&#60;?php


2&#160; 
$this-&#62;media_planning_name&#160;=&#160;str_replace(array(&#8216;/&#8216;,&#8216;\\&#8216;,&#8216;:&#8216;,&#8216;*&#8216;,&#8216;?&#8216;,&#8216;&#34;&#8216;,&#8216;&#60;&#8216;,&#8216;&#62;&#8216;,&#8216;&#124;&#8216;),&#8216;_&#8216;,&#160;trim($media_planning_name));


3&#160; 
?&#62;



3&#160; 遍历两个日期间的日期      比如，要遍历出2009-2-10，到2009-3-30 之间的日期




1&#160; 
&#60;?php&#160;for($i&#160;=&#160;$media_planning_start_date;&#160;$i&#60;=&#160;$media_planning_end_date;&#160;$i&#160;=&#160;date(&#8216;Y-m-d&#8216;,strtotime(&#34;+1&#160;days&#160;&#34;.$i))):?&#62;


2&#160; 
&#60;?php&#160;&#160;echo&#160;$i;&#160;?&#62;


3&#160; 
&#60;?php&#160;endfor;?&#62;



4&#160;<a href="http://yaron.org.cn/archives/179" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[<p><strong>1&#160; MySQL中把null值转换为0的函数？</strong></p>
<div style="font-size: 12px; line-height: 12px; font-family: courier new">
<table style="border-top-width: 0px; padding-right: 0px; padding-left: 0px; border-left-width: 0px; border-bottom-width: 0px; padding-bottom: 0px; width: 100%; padding-top: 0px; border-right-width: 0px" cellspacing="0">
<tbody>
<tr>
<td style="color: teal" valign="top" width="23">1&#160; </td>
<td width="871"><b><span style="color: #0000ff">select</span></b><span style="color: #000000">&#160;</span><span style="color: #000000">ifnull</span><span style="color: #ff0000">(</span><b><span style="color: #0000ff">null</span></b><span style="color: #ff0000">,</span><b><span style="color: #008080">0</span></b><span style="color: #ff0000">)</span><span style="color: #ff0000">;</span></td>
</tr>
</tbody>
</table></div>
<p><strong>2&#160; PHP 过滤Win系统文件名中的非法字符</strong></p>
<p> <span id="more-179"></span>
<p><strong></strong></p>
<div style="font-size: 12px; line-height: 12px; font-family: courier new">
<table style="border-top-width: 0px; padding-right: 0px; padding-left: 0px; border-left-width: 0px; border-bottom-width: 0px; padding-bottom: 0px; width: 100%; padding-top: 0px; border-right-width: 0px" cellspacing="0">
<tbody>
<tr>
<td style="color: teal" valign="top">1&#160; </td>
<td><span style="color: #000000; background-color: #ffff00">&lt;?</span><span style="color: #000000">php</span></td>
</tr>
<tr>
<td style="color: teal" valign="top">2&#160; </td>
<td><b><span style="color: #ff00ff">$this</span></b><span style="color: #ff0000">-</span><span style="color: #ff0000">&gt;</span><span style="color: #000000">media_planning_name</span><span style="color: #000000">&#160;</span><span style="color: #ff0000">=</span><span style="color: #000000">&#160;</span><b><span style="color: #00008b">str_replace</span></b><span style="color: #000000">(</span><b><span style="color: #00008b">array</span></b><span style="color: #000000">(</span><span style="color: #4682b4">&#8216;</span><span style="color: #4682b4">/</span><span style="color: #4682b4">&#8216;</span><span style="color: #000000">,</span><span style="color: #4682b4">&#8216;</span><span style="color: #4682b4">\\</span><span style="color: #4682b4">&#8216;</span><span style="color: #000000">,</span><span style="color: #4682b4">&#8216;</span><span style="color: #4682b4">:</span><span style="color: #4682b4">&#8216;</span><span style="color: #000000">,</span><span style="color: #4682b4">&#8216;</span><span style="color: #4682b4">*</span><span style="color: #4682b4">&#8216;</span><span style="color: #000000">,</span><span style="color: #4682b4">&#8216;</span><span style="color: #4682b4">?</span><span style="color: #4682b4">&#8216;</span><span style="color: #000000">,</span><span style="color: #4682b4">&#8216;</span><span style="color: #4682b4">&quot;</span><span style="color: #4682b4">&#8216;</span><span style="color: #000000">,</span><span style="color: #4682b4">&#8216;</span><span style="color: #4682b4">&lt;</span><span style="color: #4682b4">&#8216;</span><span style="color: #000000">,</span><span style="color: #4682b4">&#8216;</span><span style="color: #4682b4">&gt;</span><span style="color: #4682b4">&#8216;</span><span style="color: #000000">,</span><span style="color: #4682b4">&#8216;</span><span style="color: #4682b4">|</span><span style="color: #4682b4">&#8216;</span><span style="color: #000000">)</span><span style="color: #000000">,</span><span style="color: #4682b4">&#8216;</span><span style="color: #4682b4">_</span><span style="color: #4682b4">&#8216;</span><span style="color: #000000">,</span><span style="color: #000000">&#160;</span><b><span style="color: #00008b">trim</span></b><span style="color: #000000">(</span><b><span style="color: #ff00ff">$media_planning_name</span></b><span style="color: #000000">)</span><span style="color: #000000">)</span><span style="color: #000000">;</span></td>
</tr>
<tr>
<td style="color: teal" valign="top">3&#160; </td>
<td><span style="color: #000000; background-color: #ffff00">?&gt;</span></td>
</tr>
</tbody>
</table></div>
<p><strong>3&#160; 遍历两个日期间的日期      <br /></strong>比如，要遍历出2009-2-10，到2009-3-30 之间的日期</p>
<div style="font-size: 12px; line-height: 12px; font-family: courier new">
<table style="border-top-width: 0px; padding-right: 0px; padding-left: 0px; border-left-width: 0px; border-bottom-width: 0px; padding-bottom: 0px; width: 100%; padding-top: 0px; border-right-width: 0px" cellspacing="0">
<tbody>
<tr>
<td style="color: teal" valign="top">1&#160; </td>
<td><span style="color: #000000; background-color: #ffff00">&lt;?</span><span style="color: #000000">php</span><span style="color: #000000">&#160;</span><b><span style="color: #0000ff">for</span></b><span style="color: #000000">(</span><b><span style="color: #ff00ff">$i</span></b><span style="color: #000000">&#160;</span><span style="color: #ff0000">=</span><span style="color: #000000">&#160;</span><b><span style="color: #ff00ff">$media_planning_start_date</span></b><span style="color: #000000">;</span><span style="color: #000000">&#160;</span><b><span style="color: #ff00ff">$i</span></b><span style="color: #ff0000">&lt;</span><span style="color: #ff0000">=</span><span style="color: #000000">&#160;</span><b><span style="color: #ff00ff">$media_planning_end_date</span></b><span style="color: #000000">;</span><span style="color: #000000">&#160;</span><b><span style="color: #ff00ff">$i</span></b><span style="color: #000000">&#160;</span><span style="color: #ff0000">=</span><span style="color: #000000">&#160;</span><b><span style="color: #00008b">date</span></b><span style="color: #000000">(</span><span style="color: #4682b4">&#8216;</span><span style="color: #4682b4">Y-m-d</span><span style="color: #4682b4">&#8216;</span><span style="color: #000000">,strtotime</span><span style="color: #000000">(</span><span style="color: #4682b4">&quot;</span><span style="color: #4682b4">+1</span><span style="color: #4682b4">&#160;</span><span style="color: #4682b4">days</span><span style="color: #4682b4">&#160;</span><span style="color: #4682b4">&quot;</span><span style="color: #ff0000">.</span><b><span style="color: #ff00ff">$i</span></b><span style="color: #000000">)</span><span style="color: #000000">)</span><span style="color: #000000">)</span><span style="color: #000000">:</span><span style="color: #000000; background-color: #ffff00">?&gt;</span></td>
</tr>
<tr>
<td style="color: teal" valign="top">2&#160; </td>
<td><span style="color: #000000; background-color: #ffff00">&lt;?</span><span style="color: #000000">php</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><b><span style="color: #0000ff">echo</span></b><span style="color: #000000">&#160;</span><b><span style="color: #ff00ff">$i</span></b><span style="color: #000000">;</span><span style="color: #000000">&#160;</span><span style="color: #000000; background-color: #ffff00">?&gt;</span></td>
</tr>
<tr>
<td style="color: teal" valign="top">3&#160; </td>
<td><span style="color: #000000; background-color: #ffff00">&lt;?</span><span style="color: #000000">php</span><span style="color: #000000">&#160;</span><span style="color: #000000">endfor;</span><span style="color: #000000; background-color: #ffff00">?&gt;</span></td>
</tr>
</tbody>
</table></div>
<p><strong>4&#160; 在Eclipse Xdebug调试中，查看$this-&gt;account_id 的值      <br /></strong>$this     <br />&#8211;varHolder     <br />&#8212;-parameters     <br />查看所有参数：     <br />$this     <br />&#8211;requestParameters</p>
<p><strong>5&#160; 文件下载：</strong></p>
<div style="font-size: 12px; line-height: 12px; font-family: courier new">
<table style="border-top-width: 0px; padding-right: 0px; padding-left: 0px; border-left-width: 0px; border-bottom-width: 0px; padding-bottom: 0px; width: 100%; padding-top: 0px; border-right-width: 0px" cellspacing="0">
<tbody>
<tr>
<td style="color: teal" valign="top">1&#160; </td>
<td><span style="color: #000000; background-color: #ffff00">&lt;?</span></td>
</tr>
<tr>
<td style="color: teal" valign="top">2&#160; </td>
<td><b><span style="color: #ff00ff">$report_file</span></b><span style="color: #000000">&#160;</span><span style="color: #ff0000">=</span><span style="color: #000000">&#160;</span><span style="color: #4682b4">&#8216;</span><span style="color: #4682b4">http://</span><span style="color: #4682b4">&#8216;</span><span style="color: #ff0000">.</span><b><span style="color: #ff00ff">$this</span></b><span style="color: #ff0000">-</span><span style="color: #ff0000">&gt;</span><span style="color: #000000">getRequest</span><span style="color: #000000">(</span><span style="color: #000000">)</span><span style="color: #ff0000">-</span><span style="color: #ff0000">&gt;</span><span style="color: #000000">getHost</span><span style="color: #000000">(</span><span style="color: #000000">)</span><span style="color: #ff0000">.</span><span style="color: #4682b4">&#8216;</span><span style="color: #4682b4">/</span><span style="color: #4682b4">&#8216;</span><span style="color: #ff0000">.</span><span style="color: #000000">sfConfig::get</span><span style="color: #000000">(</span><span style="color: #4682b4">&#8216;</span><span style="color: #4682b4">sf_reports_dir</span><span style="color: #4682b4">&#8216;</span><span style="color: #000000">)</span><span style="color: #ff0000">.</span><span style="color: #4682b4">&#8216;</span><span style="color: #4682b4">/</span><span style="color: #4682b4">&#8216;</span><span style="color: #ff0000">.</span><b><span style="color: #ff00ff">$report</span></b><span style="color: #ff0000">-</span><span style="color: #ff0000">&gt;</span><span style="color: #000000">getReportPath</span><span style="color: #000000">(</span><span style="color: #000000">)</span><span style="color: #000000">;</span></td>
</tr>
<tr>
<td style="color: teal" valign="top">3&#160; </td>
<td><b><span style="color: #ff00ff">$FileParts</span></b><span style="color: #000000">&#160;</span><span style="color: #ff0000">=</span><span style="color: #000000">&#160;</span><span style="color: #000000">pathinfo</span><span style="color: #000000">(</span><b><span style="color: #ff00ff">$report_file</span></b><span style="color: #000000">)</span><span style="color: #000000">;</span></td>
</tr>
<tr>
<td style="color: teal" valign="top">4&#160; </td>
<td><b><span style="color: #ff00ff">$FileName</span></b><span style="color: #000000">&#160;</span><span style="color: #ff0000">=</span><span style="color: #000000">&#160;</span><b><span style="color: #ff00ff">$FileParts</span></b><span style="color: #000000">[</span><span style="color: #4682b4">'</span><span style="color: #4682b4">basename</span><span style="color: #4682b4">'</span><span style="color: #000000">]</span><span style="color: #000000">;</span></td>
</tr>
<tr>
<td style="color: teal" valign="top">5&#160; </td>
<td><span style="color: #008000">//</span><span style="color: #008000">文件扩展名</span></td>
</tr>
<tr>
<td style="color: teal" valign="top">6&#160; </td>
<td><b><span style="color: #0000ff">if</span></b><span style="color: #000000">&#160;</span><span style="color: #000000">(</span><b><span style="color: #00008b">isset</span></b><span style="color: #000000">(</span><b><span style="color: #ff00ff">$FileParts</span></b><span style="color: #000000">[</span><span style="color: #4682b4">'</span><span style="color: #4682b4">extension</span><span style="color: #4682b4">'</span><span style="color: #000000">]</span><span style="color: #000000">)</span><span style="color: #000000">)</span></td>
</tr>
<tr>
<td style="color: teal" valign="top">7&#160; </td>
<td><span style="color: #000000">{</span></td>
</tr>
<tr>
<td style="color: teal" valign="top">8&#160; </td>
<td><b><span style="color: #ff00ff">$Ream</span></b><span style="color: #000000">&#160;</span><span style="color: #ff0000">=</span><span style="color: #000000">&#160;</span><b><span style="color: #ff00ff">$FileParts</span></b><span style="color: #000000">[</span><span style="color: #4682b4">'</span><span style="color: #4682b4">extension</span><span style="color: #4682b4">'</span><span style="color: #000000">]</span><span style="color: #000000">;</span></td>
</tr>
<tr>
<td style="color: teal" valign="top">9&#160; </td>
<td><b><span style="color: #00008b">header</span></b><span style="color: #000000">(</span><span style="color: #000000">&#160;</span><span style="color: #4682b4">&quot;</span><span style="color: #4682b4">Content-Type:</span><span style="color: #4682b4">&#160;</span><span style="color: #4682b4">application/x-</span><span style="color: #4682b4">&quot;</span><span style="color: #ff0000">.</span><b><span style="color: #ff00ff">$Ream</span></b><span style="color: #000000">)</span><span style="color: #000000">;</span></td>
</tr>
<tr>
<td style="color: teal" valign="top">10&#160; </td>
<td><b><span style="color: #00008b">header</span></b><span style="color: #000000">(</span><span style="color: #000000">&#160;</span><span style="color: #4682b4">&quot;</span><span style="color: #4682b4">Content-Disposition:</span><span style="color: #4682b4">&#160;</span><span style="color: #4682b4">attachment;</span><span style="color: #4682b4">&#160;</span><span style="color: #4682b4">filename=</span><span style="color: #4682b4">&quot;</span><span style="color: #ff0000">.</span><b><span style="color: #ff00ff">$FileName</span></b><span style="color: #000000">)</span><span style="color: #000000">;</span></td>
</tr>
<tr>
<td style="color: teal" valign="top">11&#160; </td>
<td><span style="color: #ff0000">@</span><b><span style="color: #00008b">readfile</span></b><span style="color: #000000">(</span><b><span style="color: #ff00ff">$report_file</span></b><span style="color: #000000">)</span><span style="color: #000000">;</span></td>
</tr>
<tr>
<td style="color: teal" valign="top">12&#160; </td>
<td><b><span style="color: #00008b">exit</span></b><span style="color: #000000">;</span></td>
</tr>
<tr>
<td style="color: teal" valign="top">13&#160; </td>
<td><span style="color: #000000">}</span></td>
</tr>
<tr>
<td style="color: teal" valign="top">14&#160; </td>
<td><b><span style="color: #00008b">header</span></b><span style="color: #000000">(</span><span style="color: #000000">&#160;</span><span style="color: #4682b4">&quot;</span><span style="color: #4682b4">Content-Type:</span><span style="color: #4682b4">&#160;</span><span style="color: #4682b4">application/x-unknown</span><span style="color: #4682b4">&quot;</span><span style="color: #000000">)</span><span style="color: #000000">;</span></td>
</tr>
<tr>
<td style="color: teal" valign="top">15&#160; </td>
<td><b><span style="color: #00008b">header</span></b><span style="color: #000000">(</span><span style="color: #000000">&#160;</span><span style="color: #4682b4">&quot;</span><span style="color: #4682b4">Content-Disposition:</span><span style="color: #4682b4">&#160;</span><span style="color: #4682b4">attachment;</span><span style="color: #4682b4">&#160;</span><span style="color: #4682b4">filename=</span><span style="color: #4682b4">&quot;</span><span style="color: #ff0000">.</span><b><span style="color: #ff00ff">$FileName</span></b><span style="color: #000000">)</span><span style="color: #000000">;</span></td>
</tr>
<tr>
<td style="color: teal" valign="top">16&#160; </td>
<td><span style="color: #ff0000">@</span><b><span style="color: #00008b">readfile</span></b><span style="color: #000000">(</span><b><span style="color: #ff00ff">$report_file</span></b><span style="color: #000000">)</span><span style="color: #000000">;</span></td>
</tr>
<tr>
<td style="color: teal" valign="top">17&#160; </td>
<td><b><span style="color: #00008b">exit</span></b><span style="color: #000000">;</span></td>
</tr>
<tr>
<td style="color: teal" valign="top">18&#160; </td>
<td><span style="color: #000000; background-color: #ffff00">?&gt;</span></td>
</tr>
</tbody>
</table></div>
<p><strong>6&#160; 数组转换成字符串</strong></p>
<div style="font-size: 12px; line-height: 12px; font-family: courier new">
<table style="border-top-width: 0px; padding-right: 0px; padding-left: 0px; border-left-width: 0px; border-bottom-width: 0px; padding-bottom: 0px; width: 100%; padding-top: 0px; border-right-width: 0px" cellspacing="0">
<tbody>
<tr>
<td style="color: teal" valign="top" width="27">1&#160; </td>
<td width="866"><span style="color: #000000; background-color: #ffff00">&lt;?</span><span style="color: #000000">php</span></td>
</tr>
<tr>
<td style="color: teal" valign="top" width="27">2&#160; </td>
<td width="866"><span style="color: #008000">//</span><span style="color: #008000">涉及函数：implode()</span></td>
</tr>
<tr>
<td style="color: teal" valign="top" width="27">3&#160; </td>
<td width="866"><b><span style="color: #ff00ff">$array</span></b><span style="color: #000000">&#160;</span><span style="color: #ff0000">=</span><span style="color: #000000">&#160;</span><b><span style="color: #00008b">array</span></b><span style="color: #000000">(</span><span style="color: #4682b4">&#8216;</span><span style="color: #4682b4">last</span><span style="color: #4682b4">&#8216;</span><span style="color: #000000">,</span><span style="color: #4682b4">&#8216;</span><span style="color: #4682b4">email</span><span style="color: #4682b4">&#8216;</span><span style="color: #000000">,</span><span style="color: #4682b4">&#8216;</span><span style="color: #4682b4">phone</span><span style="color: #4682b4">&#8216;</span><span style="color: #000000">)</span><span style="color: #000000">;</span></td>
</tr>
<tr>
<td style="color: teal" valign="top" width="27">4&#160; </td>
<td width="866"><b><span style="color: #ff00ff">$str_array</span></b><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #ff0000">=</span><span style="color: #000000">&#160;</span><b><span style="color: #00008b">implode</span></b><span style="color: #000000">(</span><span style="color: #4682b4">&#8216;</span><span style="color: #4682b4">,</span><span style="color: #4682b4">&#8216;</span><span style="color: #000000">,</span><span style="color: #000000">&#160;</span><b><span style="color: #ff00ff">$array</span></b><span style="color: #000000">)</span></td>
</tr>
<tr>
<td style="color: teal" valign="top" width="27">5&#160; </td>
<td width="866"><span style="color: #008000">//</span><span style="color: #008000">&#160;</span><span style="color: #008000">last,email,phone</span></td>
</tr>
<tr>
<td style="color: teal" valign="top" width="27">6&#160; </td>
<td width="866"><span style="color: #000000; background-color: #ffff00">?&gt;</span></td>
</tr>
</tbody>
</table></div>
<p>另外一种实现方法，Join函数</p>
<div style="font-size: 12px; line-height: 12px; font-family: courier new">
<table style="border-top-width: 0px; padding-right: 0px; padding-left: 0px; border-left-width: 0px; border-bottom-width: 0px; padding-bottom: 0px; width: 100%; padding-top: 0px; border-right-width: 0px" cellspacing="0">
<tbody>
<tr>
<td style="color: teal" valign="top" width="26">1&#160; </td>
<td width="867"><span style="color: #000000; background-color: #ffff00">&lt;?</span><span style="color: #000000">php</span></td>
</tr>
<tr>
<td style="color: teal" valign="top" width="26">2&#160; </td>
<td width="867"><span style="color: #008000">//</span><span style="color: #008000">&#160;</span><span style="color: #008000">Function</span><span style="color: #008000">&#160;</span><span style="color: #008000">join()</span></td>
</tr>
<tr>
<td style="color: teal" valign="top" width="26">3&#160; </td>
<td width="867"><b><span style="color: #ff00ff">$array</span></b><span style="color: #000000">&#160;</span><span style="color: #ff0000">=</span><span style="color: #000000">&#160;</span><b><span style="color: #00008b">array</span></b><span style="color: #000000">(</span><span style="color: #4682b4">&#8216;</span><span style="color: #4682b4">lastname</span><span style="color: #4682b4">&#8216;</span><span style="color: #000000">,</span><span style="color: #000000">&#160;</span><span style="color: #4682b4">&#8216;</span><span style="color: #4682b4">email</span><span style="color: #4682b4">&#8216;</span><span style="color: #000000">,</span><span style="color: #000000">&#160;</span><span style="color: #4682b4">&#8216;</span><span style="color: #4682b4">phone</span><span style="color: #4682b4">&#8216;</span><span style="color: #000000">)</span><span style="color: #000000">;</span></td>
</tr>
<tr>
<td style="color: teal" valign="top" width="26">4&#160; </td>
<td width="867"><b><span style="color: #ff00ff">$comma_separated</span></b><span style="color: #000000">&#160;</span><span style="color: #ff0000">=</span><span style="color: #000000">&#160;</span><b><span style="color: #00008b">join</span></b><span style="color: #000000">(</span><span style="color: #4682b4">&quot;</span><span style="color: #4682b4">,</span><span style="color: #4682b4">&quot;</span><span style="color: #000000">,</span><span style="color: #000000">&#160;</span><b><span style="color: #ff00ff">$array</span></b><span style="color: #000000">)</span><span style="color: #000000">;</span></td>
</tr>
<tr>
<td style="color: teal" valign="top" width="26">5&#160; </td>
<td width="867"><b><span style="color: #0000ff">echo</span></b><span style="color: #000000">&#160;</span><b><span style="color: #ff00ff">$comma_separated</span></b><span style="color: #000000">;</span><span style="color: #000000">&#160;</span><span style="color: #008000">//</span><span style="color: #008000">&#160;</span><span style="color: #008000">lastname,email,phone</span></td>
</tr>
<tr>
<td style="color: teal" valign="top" width="26">6&#160; </td>
<td width="867"><span style="color: #000000; background-color: #ffff00">?&gt;</span></td>
</tr>
</tbody>
</table></div>
]]></content:encoded>
			<wfw:commentRss>http://yaron.org.cn/archives/179/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Symfony 框架基础知识点集锦二</title>
		<link>http://yaron.org.cn/archives/175</link>
		<comments>http://yaron.org.cn/archives/175#comments</comments>
		<pubDate>Wed, 16 Dec 2009 07:50:00 +0000</pubDate>
		<dc:creator>Yaron</dc:creator>
				<category><![CDATA[Symfony]]></category>

		<guid isPermaLink="false">http://yaron.org.cn/archives/175</guid>
		<description><![CDATA[美化URL&#160; 以这种形式展示 http://copyscreen.loc/hylink_dev.php/media_planning_show/5     在routing.yml:     show_media_planning:     &#160; url:&#160;&#160;&#160;&#160; /media_planning_show/:media_planning_id<a href="http://yaron.org.cn/archives/175" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[<p>美化URL&#160; <br />以这种形式展示 <a href="http://copyscreen.loc/hylink_dev.php/media_planning_show/5">http://copyscreen.loc/hylink_dev.php/media_planning_show/5</a>     <br />在routing.yml:     <br />show_media_planning:     <br />&#160; url:&#160;&#160;&#160;&#160; /media_planning_show/:media_planning_id     <br />&#160; param:&#160;&#160; { module: mediaplanning, action: showMediaPlanning }</p>
<p> <span id="more-175"></span>
<p>在超链接中：    <br />1. &lt;a href=&quot;&lt;?php echo url_for(&quot;@show_media_planning?media_planning_id={$media_planning-&gt;getId()}&quot;) ?&gt;&quot;&gt;xx&lt;/a&gt;     <br />2. &lt;?php echo link_to(__(&#8216;Detail&#8217;, null, &#8216;navigation&#8217;),&quot;@show_media_planning?media_planning_id={$media_planning-&gt;getId()}&quot;)?&gt;</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; 2009-06-19 11:42:51 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>创建数据库schema，symfony支持两种方式：一种是从编写schema.yml开始，然后用build-sql、insert-sql任务来创建表；另一种是反过来，先在MySQL中定义好表和关联，然后用build-schema来创建schema.yml。这两种方式是等效的，看个人的喜好而定。</p>
<p>1.0 版本需要在propel.ini文件中加入这句：    <br />propel.database.url&#160;&#160;&#160;&#160;&#160;&#160;&#160; = mysql://root@localhost/copy_screen</p>
<p>1.0    <br />php symfony propel-build-schema     <br />php symfony propel-build-model</p>
<p>1.2    <br />php symfony propel:build-schema     <br />php symfony propel:build-model</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; 2009-06-19 11:35:12 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>Symfony 创建项目时出现错误如下：    <br />A project named &quot;CopyScreen&quot; already exists in this directory.</p>
<p>原因之一是：进入了Symfony的bin目录执行项目创建动作，正确方法是在项目目录下创建。    <br />错误写法：d:\projectA\lib\vendor\symfony\data\bin&gt;php symfony init-project projectA     <br />正确写法：d:\projectA&gt; php lib\vendor\symfony\data\bin\symfony init-project projectA</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; 2009-06-08 15:46:30 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>复制记录，为新纪录，二者主索引不同，修改部分列值：    <br />$mNewObj = new DbMccAccount();     <br />$mObj = $mccAccount['mobj'];     <br />$mObj-&gt;setId(null);     <br />$mObj-&gt;setSemUserId($uid);     <br />$mObj-&gt;copyInto($mNewObj);     <br />$mNewObj-&gt;save();</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; 2009-06-08 12:07:34 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>相关联数据表的删除操作    <br />user(id,name,trackingID)     <br />tracking(id,name)     <br />已知userID，     <br />$user = DbUserPeer::retrieveByPK($userID);     <br />DbTrackingPeer::doDelete($user);     <br />DbUserPeer::doDelete($id)</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; 2009-05-31 10:49:49 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>YAML (IPA: /j?m?l/, 尾音类似camel骆驼) 是一个可读性高，用来表达资料序列的程式语言    <br />http://www.yaml.org/</p>
<p>语法：    <br />Structure通过空格来展示。Sequence(连续、一连串)里的项用&quot;-&quot;来代表，Map里的键值对用&quot;:&quot;分隔.     <br />john.yaml:     <br />&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;     <br />name: John Smith     <br />age:&#160; 37     <br />spouse:     <br />&#160;&#160;&#160; name: Jane Smith     <br />&#160;&#160;&#160; age:&#160; 25     <br />children:     <br />&#160;&#160;&#160; -&#160;&#160; name: Jimmy Smith     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; age:&#160; 15     <br />&#160;&#160;&#160; -&#160;&#160; name: Jenny Smith     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; age&#160;&#160; 12</p>
<p>数组表示：    <br />&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;     <br />$john = array(&#8216;name&#8217;&#160;&#160;&#160; =&gt; &#8216;John Smith&#8217;,     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#8216;age&#8217;&#160;&#160;&#160;&#160; =&gt; 37,     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#8217;spouse&#8217;&#160; =&gt; array(&#8216;name&#8217; =&gt; &#8216;Jane Smith&#8217;, &#8216;age&#8217; =&gt; 25),     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#8216;children&#8217;=&gt; array(0 =&gt; array(&#8216;name&#8217; =&gt; &#8216;Jimmy Smith&#8217;, &#8216;age&#8217; =&gt; 5),     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 1 =&gt; array(&#8216;name&#8217; =&gt; &#8216;Jenny Smith&#8217;, &#8216;age&#8217; =&gt; 3)     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; )     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; );     <br />&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>PHP 解析 Yaml 文件的类：    <br />&#160; &#8211; syck&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; # syck bindings (YAML 1.0)     <br /><a href="http://pecl.php.net/package/syck">http://pecl.php.net/package/syck</a>     <br />&#160; &#8211; spyc&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; # yaml loader/dumper (YAML 1.?)     <br /><a href="http://code.google.com/p/spyc/">http://code.google.com/p/spyc/</a></p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>Symfony&#160; 命令    <br />$ symfony init-module frontend feed&#160; 创建模块</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;    <br />$con = Propel::getConnection();     <br />$query = &#8217;select %s.*, %s.name from %s left join %s on %s=%s where %s = ?&#8217;;     <br />$query = sprintf($query,     <br />DbUserPeer::TABLE_NAME,     <br />DbAuthorityGradePeer::TABLE_NAME,     <br />DbUserPeer::TABLE_NAME,     <br />DbAuthorityGradePeer::TABLE_NAME,     <br />DbUserPeer::AUTHORITY_GRADE_ID,     <br />DbAuthorityGradePeer::ID,     <br />DbUserPeer::ID     <br />);     </p>
<p>$stmt = $con-&gt;prepareStatement($query);     <br />$stmt-&gt;setInt(1,$user_id);     <br />$rs = $stmt-&gt;executeQuery();</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; 2009-04-27 14:22:53 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>routing.yml 路由表    <br />注意，系统选择路由，会自上而下的匹配，如果上面有符合条件的规则，就不会再向下匹配了。     <br />所以希望展示自定义规则的话，那就将自定义规则往上提。</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>$c = new Criteria();    <br />$c-&gt;add(QuestionPeer::STRIPPED_TITLE,$this-&gt;getRequestParameter(&#8217;stripped_title&#8217;));     <br />$this-&gt;questions = QuestionPeer::doSelect($c);     <br />$this-&gt;question = $this-&gt;questions[0];     <br />$this-&gt;forward404Unless($this-&gt;questions);     <br />// $this-&gt;questions = QuestionPeer::doSelect($c); 返回的是一组对象，是一个对象数组。     <br />在模板中不能直接$questions-&gt;getId()等引用，而是读取其中一个元素(就是对象),然后$question-&gt;getId()引用。</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>[propel-om] Processing: schema.xml    <br />Execution of target &quot;om-template&quot; failed for the following reason: D:\workspace\     <br />askeet\lib\vendor\symfony\lib\vendor\propel-generator\build-propel.xml:470:1: No     <br />package found for database &quot;propel&quot; in schema.xml. The propel.packageObjectMode     <br />l property requires the package attribute to be set for each database.     <br />[phingcall] D:\workspace\askeet\lib\vendor\symfony\lib\vendor\propel-generator\b     <br />uild-propel.xml:470:1: No package found for database &quot;propel&quot; in schema.xml. The     <br />propel.packageObjectModel property requires the package attribute to be set for     <br />each database.     <br />i had the same problem and changed     <br />&lt;database name=&quot;propel&quot; defaultIdMethod=&quot;native&quot; noxsd=&quot;true&quot;&gt;     <br />to     <br />&lt;database name=&quot;propel&quot; defaultIdMethod=&quot;native&quot; noxsd=&quot;true&quot; package=&quot;lib.model&quot;&gt;     <br />was a lucky guess.     <br />and i&#8217;m getting excited. 2 days and almost made it thru the 2nd tutorial. hehe.</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>How to Get Action Name?    <br />To get current action name in action file:     <br />sfContext::getInstance()-&gt;getActionName();     <br />To get current action name in template file:     <br />$sf_context-&gt;getActionName();</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>routing.yml    <br /># homepage defined The default Page When logged successfully.     <br />homepage:     <br />&#160; url:&#160;&#160; /     <br />&#160; param: { module: job, action: index }</p>
]]></content:encoded>
			<wfw:commentRss>http://yaron.org.cn/archives/175/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Symfony 框架基础知识点集锦一</title>
		<link>http://yaron.org.cn/archives/167</link>
		<comments>http://yaron.org.cn/archives/167#comments</comments>
		<pubDate>Tue, 15 Dec 2009 06:12:00 +0000</pubDate>
		<dc:creator>Yaron</dc:creator>
				<category><![CDATA[Symfony]]></category>

		<guid isPermaLink="false">http://yaron.org.cn/archives/167</guid>
		<description><![CDATA[
日期间天数的计算 

$a=date(&#34;y-m-d&#34;,time());&#160;&#160; $b=$resultarray['date'];&#160;&#160; $c=strtotime($a)-strtotime($b);&#160;&#160; $c=ceil($c/(60*60*24)); 
 

&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; 2009-07-27 17:33:04 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; 
一条记录，Copy为另一条记录 
$mNewObj&#160;&#160;&#160; = new DbMccAccount();    $mObj&#160;&#160;&#160; =<a href="http://yaron.org.cn/archives/167" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[</p>
<p>日期间天数的计算 </p>
<div style="font-size: 12px; line-height: 12px; font-family: courier new"></div>
<p>$a=date(&quot;y-m-d&quot;,time());&#160;&#160; <br />$b=$resultarray['date'];&#160;&#160; <br />$c=strtotime($a)-strtotime($b);&#160;&#160; <br />$c=ceil($c/(60*60*24)); </p>
<p> <span id="more-167"></span>
</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; 2009-07-27 17:33:04 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; </p>
<p>一条记录，Copy为另一条记录 </p>
<p>$mNewObj&#160;&#160;&#160; = new DbMccAccount();    <br />$mObj&#160;&#160;&#160; = $mccAccount['mobj'];     <br />$mObj-&gt;setId(null);     <br />$mObj-&gt;setSemUserId($uid);     <br />$mObj-&gt;copyInto($mNewObj);     <br />$mNewObj-&gt;save();     <br />$mid&#160;&#160;&#160; = $mNewObj-&gt;getId();     <br />$aNewObj&#160;&#160;&#160; = new DbAccount();     <br />$aObj&#160;&#160;&#160; = $mccAccount['aobj'];     <br />$aObj-&gt;setId(&#8221;);     <br />$aObj-&gt;setSemMccAccountId($mid);     <br />$aObj-&gt;copyInto($aNewObj);     <br />$aNewObj-&gt;save(); </p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;    <br />同一个字段的两个条件书写方法： </p>
<p>$c1= $criteria_task-&gt;getNewCriterion(SpotTaskPeer::SPOT_PLAN_DATE, $start_date, Criteria::GREATER_EQUAL);    <br />$c2= $criteria_task-&gt;getNewCriterion(SpotTaskPeer::SPOT_PLAN_DATE, $end_date, Criteria::LESS_EQUAL);     <br />$c1-&gt;addAnd($c2); </p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; 2009-07-15 09:10:14 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; </p>
<p>$c = new Criteria();    <br />$c-&gt;add(AuthorPeer::LAST_NAME, array(&quot;Tolstoy&quot;, &quot;Dostoevsky&quot;, &quot;Bakhtin&quot;), Criteria::IN); </p>
<p>$authors = AuthorPeer::doSelect($c); </p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; 2009-07-14 16:30:37 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; </p>
<p>// Find all authors with first name &quot;Leo&quot; OR last name of    <br />// &quot;Tolstoy&quot;, &quot;Dostoevsky&quot;, or &quot;Bakhtin&quot;     <br />$c = new Criteria();     <br />$cton1 = $c-&gt;getNewCriterion(AuthorPeer::FIRST_NAME, &quot;Leo&quot;);     <br />$cton2 = $c-&gt;getNewCriterion(AuthorPeer::LAST_NAME,     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; array(&quot;Tolstoy&quot;, &quot;Dostoevsky&quot;, &quot;Bakhtin&quot;), Criteria::IN);     <br />// combine them     <br />$cton1-&gt;addOr($cton2);     <br />// add to Criteria     <br />$c-&gt;add($cton1); </p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; 2009-07-09 11:44:52 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;    <br />模板从配置文件中读取值： </p>
<p>&lt;!&#8211; apps/frontend/modules/job/indexSuccess.php &#8211;&gt;    <br />&lt;?php foreach ($category-&gt;getActiveJobs(sfConfig::get(&#8216;app_max_jobs_on_homepage&#8217;)) as $i =&gt; $job): ?&gt;</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; 2009-07-07 10:08:10 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;    <br />模版中 设置 获得 当前用户的语言     <br />&lt;?php use_helper(&#8216;Number&#8217;) ?&gt;     <br />&lt;?php $sf_user-&gt;setCulture(&#8216;en_US&#8217;) ?&gt;     <br />&lt;?php $sf_user-&gt;getCulture() ?&gt;     <br />你无需明确地将culture值传递给辅助函数。辅助函数会在当前的会话对象中     <br />自动找到culture值。例13－4中列出的辅助函数在输出数据时都会考虑用户     <br />的culture值。 </p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; 2009-07-06 16:23:24 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;    <br />删除记录     <br />Example 1: Delete using primary key     <br />&lt;?php </p>
<p>BookPeer::doDelete(1);    <br />Example 2: Delete using instantiated object     <br />&lt;?php </p>
<p>$book = BookPeer::retrieveByPK(1);    <br />BookPeer::doDelete($book); </p>
<p>$c&#160;&#160;&#160; = new Criteria();    <br />$c-&gt;add(JobeetJobPeer::TYPE, &#8216;part-time&#8217;);     <br />$jobeet_jobs&#160;&#160;&#160; = JobeetJobPeer::doDelete($c); </p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; 2009-07-06 10:45:37 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;    <br />select 列表书写方式：     <br />1.select_tag&#160; +&#160;&#160; objects_for_select     <br />&lt;?php echo select_tag(&#8216;advertiser_exist&#8217;, objects_for_select($advertisers_list, &#8216;getId&#8217;, &#8216;getAdvertiserName&#8217;)?&gt; </p>
<p>2. select_tag + options_for_select    <br />&lt;?php echo select_tag(&#8216;channel&#8217;, options_for_select(array()) ?&gt; </p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; 2009-07-06 10:15:23 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; </p>
<p>表单动作，位于同一个动作脚本中：    <br />// mymodule/actions/actions.class.php     <br />public function executeEditAuthor()     <br />{     <br />&#160; if ($this-&gt;getRequest()-&gt;getMethod() != sfRequest::POST)     <br />&#160; {     <br />&#160;&#160;&#160; // 显示表单     <br />&#160;&#160;&#160; return sfView::SUCCESS;     <br />&#160; }     <br />&#160; else     <br />&#160; {     <br />&#160;&#160;&#160; // 对提交的表单加以处理     <br />&#160;&#160;&#160; $name = $this-&gt;getRequestParameter(&#8216;name&#8217;);     <br />&#160;&#160;&#160; &#8230;     <br />&#160;&#160;&#160; $this-&gt;redirect(&#8216;mymodule/anotheraction&#8217;);     <br />&#160; }     <br />}     <br />这段代码要能正常工作，表单处理和表单显示必须在同一个动作中。     <br />// mymodule/templates/editAuthorSuccess.php </p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; 2009-06-25 10:33:41 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;    <br />不显示到模版中的动作     <br />//&#160;&#160;&#160; return sfView::NONE; </p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; 2009-06-25 09:56:29 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;    <br />Vim中u是撤销当前操作，U是恢复刚才撤销的操作。 </p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; 2009-06-25 09:44:55 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;    <br />PHP     <br />各个方法中通用的变量需要在Class中预定义。     <br />引用的时候使用$this指针。 </p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; 2009-06-25 09:44:25 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;    <br />General DB API Changes ? </p>
<p>Of course, any code in your application that was using the Creole API (e.g. returned from Propel::getConnection()) will now need to use the PDO API. </p>
<p>See <a href="http://www.php.net/pdo">http://www.php.net/pdo</a> for more information on the PDO API. Generally, the PDO API is quite similar to Creole&#8217;s, so updates are generally quite easy. </p>
<p>For example: </p>
<p>Propel 1.2 + Creole code: </p>
<p>&lt;?php </p>
<p>$con = Propel::getConnection(SomeTablePeer::DATABASE_NAME);    <br />$stmt = $con-&gt;prepareStatement(&quot;SELECT * FROM some_table WHERE name = ?&quot;);     <br />$stmt-&gt;setString(1, $name);     <br />$rs = $stmt-&gt;executeQuery();     <br />while($rs-&gt;next()) {     <br />&#160;&#160; print &quot;Name: &quot; . $rs-&gt;getString(&quot;name&quot;) . &quot;\n&quot;;     <br />} </p>
<p>完整版    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $con = Propel::getConnection();     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $query = &#8217;select %s.*, %s.action_name from %s, %s where %s=%s and %s=?&#8217;;     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $query = sprintf($query,     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; DbAuthorityGradeRelActionPeer::TABLE_NAME,     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; DbAuthorityActionPeer::TABLE_NAME,     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; DbAuthorityGradeRelActionPeer::TABLE_NAME,     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; DbAuthorityActionPeer::TABLE_NAME,     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; DbAuthorityGradeRelActionPeer::SEM_AUTHORITY_ACTION_ID,     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; DbAuthorityActionPeer::ID,     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; DbAuthorityGradeRelActionPeer::SEM_AUTHORITY_GRADE_ID     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; ); </p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; $stmt = $con-&gt;prepareStatement($query);    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $stmt-&gt;setInt(1,$aid);     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $rs = $stmt-&gt;executeQuery();     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; return $rs; </p>
<p>Propel 1.3 + PDO code: </p>
<p>&lt;?php </p>
<p>$con = Propel::getConnection(SomeTablePeer::DATABASE_NAME);    <br />$stmt = $con-&gt;prepare(&quot;SELECT * FROM some_table WHERE name = ?&quot;);     <br />$stmt-&gt;bindValue(1, $name);     <br />$stmt-&gt;execute();     <br />while($row = $stmt-&gt;fetch()) {     <br />&#160;&#160; print &quot;Name: &quot; . $row['name'] . &quot;\n&quot;;     <br />} </p>
<p><a href="http://propel.phpdb.org/trac/wiki/Users/Documentation/1.3/Upgrading">http://propel.phpdb.org/trac/wiki/Users/Documentation/1.3/Upgrading</a></p>
<p>example：    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $con&#160;&#160;&#160; = Propel::getConnection();     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $query&#160;&#160;&#160; = &quot;select %s.*,%s.* from %s left join %s on %s=%s &quot;;     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $query&#160;&#160;&#160; .= &quot;where %s=? and %s&gt;? and %s&lt;?&quot;;     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $query&#160;&#160;&#160; = sprintf($query,     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; MediaPlanPeer::TABLE_NAME,     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; AdvertisersPeer::TABLE_NAME,     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; MediaPlanPeer::TABLE_NAME,     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; AdvertisersPeer::TABLE_NAME,     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; MediaPlanPeer::ADVERTISER_ID,     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; AdvertisersPeer::ID     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; );     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $stmt&#160;&#160;&#160; = $con-&gt;prepare($query);     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $stmt-&gt;execute();     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $hell&#160;&#160;&#160; = $stmt;     <br />//&#160;&#160;&#160;&#160;&#160;&#160;&#160; $this-&gt;media_plannings&#160;&#160;&#160; = $stmt-&gt;fetch(); </p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; $this-&gt;media_plannings&#160;&#160;&#160; = MediaPlanPeer::populateObjects($stmt); </p>
<p>while($row = $hell-&gt;fetch()) {    <br />&#160;&#160; print &quot;Name: &quot; . $row['media_plan_name'] . &quot;&lt;br /&gt;&quot;;     <br />} </p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; 2009-06-24 09:07:48 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;    <br />i18n下面的文件名，不能带有下划线。 </p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; 2009-06-01 09:16:20 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; </p>
<p>表单辅助函数 </p>
<p>form_tag()    <br />&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; </p>
<p>&#160; &lt;?php echo form_tag(&#8216;module/action&#8217;) ?&gt;    <br />&#160;&#160;&#160; =&gt; &lt;form method=&quot;post&quot; action=&quot;module/action&quot;&gt; </p>
<p>&#160; &lt;?php echo form_tag(&#8216;module/action&#8217;, &#8216;method=get multipart=true class=simpleForm&#8217;) ?&gt;    <br />&#160;&#160;&#160; =&gt; &lt;form method=&quot;get&quot; action=&quot;module/action&quot; enctype=&quot;multipart/form-data&quot; class=&quot;simpleForm&quot;&gt; </p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;- </p>
<p>标准的表单元素 </p>
<p>input_tag(&#8216;name&#8217;, &#8216;default value&#8217;, &#8216;maxlength=20&#8242;) </p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; 2009-05-31 16:16:19 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; </p>
<p>模版快捷变量 </p>
<p>在模版里，有一些Symfony变量可以直接使用。通过这些快捷变量可以从Symfony的对象中取得一些最常用的模版信息：    <br />$sf_context:&#160; 完整的环境对象(context object), sfContext类的实例     <br />$sf_request:&#160; 请求对象，sfRequest类的实例     <br />$sf_params:&#160;&#160; 请求的参数     <br />$sf_user:&#160;&#160;&#160;&#160; 当前的用户session对象，sfUser类的实例 </p>
<p>$sf_request 请求对象的实例： </p>
<p>| 模版中获得请求的参数(<a href="http://www.a.cn/showpage.php?id=1，id就是请求showpage.php的参数)">http://www.a.cn/showpage.php?id=1，id就是请求showpage.php的参数)</a>     <br />| &lt;?php echo $sf_request-&gt;getParameter(&#8216;id&#8217;); ?&gt;     <br />| 简版:     <br />| &lt;?php echo $sf_params-&gt;get(&#8216;id&#8217;); ?&gt;     <br />|     <br />| 在动作(action)里面，相当于如下代码：     <br />| echo $this-&gt;getRequestParameter(&#8216;id&#8217;) </p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; </p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; 2009-05-31 16:16:06 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; </p>
<p>模版中使用 Helper 时，先使用 use_helper() 函数载入：    <br />&lt;?php use_helper(&#8216;Text&#8217;)?&gt; </p>
<p>TextHelper.php </p>
<p>truncate_text()&#160;&#160;&#160;&#160;&#160;&#160;&#160; 字符串截取函数    <br />highlight_text()&#160;&#160;&#160; 高亮显示函数     <br />excerpt_text()&#160;&#160;&#160;&#160;&#160;&#160;&#160; 截取摘要函数     <br />wrap_text()&#160;&#160;&#160;&#160;&#160;&#160;&#160; 自定义行宽函数     <br />simple_format_text()&#160;&#160;&#160; 格式化文本     <br />auto_link_text()&#160;&#160;&#160; 自动设置文本的的链接     <br />strip_links_text()&#160;&#160;&#160; 去除文本中的链接     <br />_auto_link_urls()&#160;&#160;&#160; 转换文本中的URL为可点击的URL     <br />_auto_link_email_addresses()&#160;&#160;&#160; 转换文本中Email为可点击的Email </p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; 2009-05-31 15:19:05 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; </p>
<p>为项目设置虚拟主机 </p>
<p>NameVirtualHost *:80    <br />&lt;VirtualHost *:80&gt;     <br />&#160; ServerName weblog.loc     <br />&#160; DocumentRoot &quot;D:\workspace\weblog\web&quot;     <br />&#160; &lt;Directory &quot;D:\workspace\weblog\web&quot;&gt;     <br />&#160;&#160;&#160; Options Indexes FollowSymLinks Includes ExecCGI     <br />&#160;&#160;&#160; AllowOverride All     <br />&#160;&#160;&#160; Order allow,deny     <br />&#160;&#160;&#160; Allow from all     <br />&#160; &lt;/Directory&gt; </p>
<p>&#160; Alias /sf &quot;D:\xampp\php5\pear\data\symfony\web\sf&quot;    <br />&#160; &lt;Directory &quot;D:\xampp\php5\pear\data\symfony\web\sf&quot;&gt;     <br />&#160;&#160;&#160; AllowOverride All     <br />&#160;&#160;&#160; Allow from All     <br />&#160; &lt;/Directory&gt;     <br />&lt;/VirtualHost&gt; </p>
<p>本机解析项目域名    <br />打开文件：C:\WINDOWS\system32\drivers\etc\hosts     <br />增加相应域名解析：     <br />127.0.0.1&#160;&#160;&#160;&#160;&#160;&#160; weblog.loc     <br />127.0.0.1&#160;&#160;&#160;&#160;&#160;&#160; uii.loc     <br />127.0.0.1&#160;&#160;&#160;&#160;&#160;&#160; jobeet.loc     <br />127.0.0.1&#160;&#160;&#160;&#160;&#160;&#160; askeet.loc     <br />127.0.0.1&#160;&#160;&#160;&#160;&#160;&#160; mysql.loc     <br />127.0.0.1&#160;&#160;&#160;&#160;&#160;&#160; localhost </p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; 2009-05-31 11:59:27 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; </p>
<p>Symfony 建立项目流程 </p>
<p>创建项目：    <br />D:\workspace\weblog&gt; symfony init-project weblog </p>
<p>创建模型：    <br />// Create a schema.yml file in ProjecName/config/     <br />D:\workspace\weblog&gt; symfony propel-build-model </p>
<p>创建数据库：    <br />D:\workspace\weblog&gt;symfony propel-build-sql     <br />D:\workspace\weblog&gt;symfony propel-insert-sql </p>
<p>创建应用程序：    <br />D:\workspace\weblog&gt;symfony init-app frontend </p>
<p>创建模块：    <br />D:\workspace\weblog&gt;symfony init-module frontend post     <br />D:\workspace\weblog&gt;symfony init-module frontend comment     <br />(创建脚手架：     <br />D:\workspace\weblog&gt;symfony propel-generate-crud frontend post Post     <br />D:\workspace\weblog&gt;symfony propel-generate-crud frontend comment Comment     <br />) </p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; 2009-05-31 10:50:10 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; </p>
<p>表单验证    <br />&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; </p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; methods:    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; get:&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; [password1, password2]     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; post:&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; [password1, password2]     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; names:     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; password1:     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; required:&#160;&#160;&#160;&#160; Yes     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; required_msg: Please enter a password     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; password2:     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; required:&#160;&#160;&#160;&#160; Yes     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; required_msg: Please retype the password     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; validators:&#160;&#160; passwordValidator     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; passwordValidator:     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; class:&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; sfCompareValidator     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; param:     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; check:&#160;&#160;&#160;&#160;&#160;&#160;&#160; password1     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; compare_error: The passwords you entered do not match. Please try again.     <br />/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/i </p>
<p>emailValidator:    <br />&#160; class:&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; sfRegexValidator     <br />&#160;&#160;&#160; param:     <br />&#160;&#160;&#160;&#160;&#160; match:&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Yes     <br />&#160;&#160;&#160;&#160;&#160; match_error:&#160;&#160;&#160;&#160;&#160; Email 格式不正确     <br />&#160;&#160;&#160;&#160;&#160; pattern:&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/i     <br />&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
]]></content:encoded>
			<wfw:commentRss>http://yaron.org.cn/archives/167/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>在 Textarea 中输入制表符</title>
		<link>http://yaron.org.cn/archives/161</link>
		<comments>http://yaron.org.cn/archives/161#comments</comments>
		<pubDate>Fri, 11 Dec 2009 08:35:52 +0000</pubDate>
		<dc:creator>Yaron</dc:creator>
				<category><![CDATA[JS脚本编程]]></category>

		<guid isPermaLink="false">http://yaron.org.cn/archives/161</guid>
		<description><![CDATA[&#160;&#160;&#160;&#160;&#160; 在 Textarea 中单击Tab键时，会切换控件焦点，而不是在 Textarea 中输入制表符。如何才能实现制表符的输入呢？
 

&#160;&#160;&#160;&#160; 看代码：




1&#160; 
function&#160;insertTabToTextarea(event){&#160;&#160;


2&#160; 
&#160;&#160;&#160;&#160;event&#160;=&#160;event&#160;?&#160;event&#160;:&#160;window.event;


3&#160; 
&#160;&#160;&#160;&#160;if&#160;(event.keyCode&#160;==&#160;9)&#160;{


4&#160; 
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;event.returnValue&#160;=&#160;false;


5&#160; 
&#160;&#160;&#160; &#160;&#160;&#160; var&#160;textEl&#160;=&#160;&#160;$(&#34;ads_ad_content&#34;);


6&#160; 
&#160;&#160;&#160; &#160;&#160;&#160; var&#160;text&#160;=&#160;&#8216;\t&#8216;;


7&#160; 
&#160;&#160;&#160; &#160;&#160;&#160;/**//*@cc_on


8&#160;<a href="http://yaron.org.cn/archives/161" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[<p>&#160;&#160;&#160;&#160;&#160; 在 Textarea 中单击Tab键时，会切换控件焦点，而不是在 Textarea 中输入制表符。如何才能实现制表符的输入呢？</p>
<p> <span id="more-161"></span>
</p>
<p>&#160;&#160;&#160;&#160; 看代码：</p>
<div style="font-size: 12px; line-height: 8px; font-family: courier new">
<table style="border-top-width: 0px; padding-right: 0px; padding-left: 0px; border-left-width: 0px; border-bottom-width: 1px; padding-bottom: 0px; width: 100%; padding-top: 0px; border-right-width: 0px" cellspacing="0">
<tbody>
<tr>
<td style="color: teal" valign="top" width="10">1&#160; </td>
<td width="569"><b><span style="color: #0000ff">function</span></b><span style="color: #000000">&#160;</span><span style="color: #000000">insertTabToTextarea</span><span style="color: #ff0000">(</span><span style="color: #ff00ff">event</span><span style="color: #ff0000">)</span><span style="color: #000000">{</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span></td>
</tr>
<tr>
<td style="color: teal" valign="top" width="10">2&#160; </td>
<td width="569"><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #ff00ff">event</span><span style="color: #000000">&#160;</span><span style="color: #ff0000">=</span><span style="color: #000000">&#160;</span><span style="color: #ff00ff">event</span><span style="color: #000000">&#160;</span><span style="color: #ff0000">?</span><span style="color: #000000">&#160;</span><span style="color: #ff00ff">event</span><span style="color: #000000">&#160;</span><span style="color: #ff0000">:</span><span style="color: #000000">&#160;</span><span style="color: #ff00ff">window</span><span style="color: #ff0000">.</span><span style="color: #ff00ff">event</span><span style="color: #ff0000">;</span></td>
</tr>
<tr>
<td style="color: teal" valign="top" width="10">3&#160; </td>
<td width="569"><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><b><span style="color: #0000ff">if</span></b><span style="color: #000000">&#160;</span><span style="color: #ff0000">(</span><span style="color: #ff00ff">event</span><span style="color: #ff0000">.</span><span style="color: #ff00ff">keyCode</span><span style="color: #000000">&#160;</span><span style="color: #ff0000">=</span><span style="color: #ff0000">=</span><span style="color: #000000">&#160;</span><b><span style="color: #008080">9</span></b><span style="color: #ff0000">)</span><span style="color: #000000">&#160;</span><span style="color: #000000">{</span></td>
</tr>
<tr>
<td style="color: teal" valign="top" width="10">4&#160; </td>
<td width="569"><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #ff00ff">event</span><span style="color: #ff0000">.</span><span style="color: #ff00ff">returnValue</span><span style="color: #000000">&#160;</span><span style="color: #ff0000">=</span><span style="color: #000000">&#160;</span><b><span style="color: #0000ff">false</span></b><span style="color: #ff0000">;</span></td>
</tr>
<tr>
<td style="color: teal" valign="top" width="10">5&#160; </td>
<td width="569"><span style="color: #000000">&#160;&#160;&#160; </span><span style="color: #000000">&#160;&#160;&#160; </span><b><span style="color: #0000ff">var</span></b><span style="color: #000000">&#160;</span><span style="color: #000000">textEl</span><span style="color: #000000">&#160;</span><span style="color: #ff0000">=</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #ff0000">$</span><span style="color: #ff0000">(</span><span style="color: #4682b4">&quot;</span><span style="color: #4682b4">ads_ad_content</span><span style="color: #4682b4">&quot;</span><span style="color: #ff0000">)</span><span style="color: #ff0000">;</span></td>
</tr>
<tr>
<td style="color: teal" valign="top" width="10">6&#160; </td>
<td width="569"><span style="color: #000000">&#160;&#160;&#160; </span><span style="color: #000000">&#160;&#160;&#160; </span><b><span style="color: #0000ff">var</span></b><span style="color: #000000">&#160;</span><span style="color: #ff00ff">text</span><span style="color: #000000">&#160;</span><span style="color: #ff0000">=</span><span style="color: #000000">&#160;</span><span style="color: #ff0000">&#8216;</span><span style="color: #ff0000">\</span><span style="color: #000000">t</span><span style="color: #ff0000">&#8216;</span><span style="color: #ff0000">;</span></td>
</tr>
<tr>
<td style="color: teal" valign="top" width="10">7&#160; </td>
<td width="569"><span style="color: #000000">&#160;&#160;&#160; </span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #008000">/*</span><span style="color: #008000">*/</span><span style="color: #008000">/*</span><span style="color: #008000">@cc_on</span></td>
</tr>
<tr>
<td style="color: teal" valign="top" width="10">8&#160; </td>
<td width="569"><span style="color: #008000">&#160;&#160;&#160; </span><span style="color: #008000">&#160;</span><span style="color: #008000">&#160;</span><span style="color: #008000">&#160;</span><span style="color: #008000">&#160;</span><span style="color: #008000">@set</span><span style="color: #008000">&#160;</span><span style="color: #008000">@ie</span><span style="color: #008000">&#160;</span><span style="color: #008000">=</span><span style="color: #008000">&#160;</span><span style="color: #008000">true</span></td>
</tr>
<tr>
<td style="color: teal" valign="top" width="10">9&#160; </td>
<td width="569"><span style="color: #008000">&#160;&#160;&#160; </span><span style="color: #008000">&#160;</span><span style="color: #008000">&#160;</span><span style="color: #008000">&#160;</span><span style="color: #008000">&#160;</span><span style="color: #008000">@if</span><span style="color: #008000">&#160;</span><span style="color: #008000">(@ie)</span></td>
</tr>
<tr>
<td style="color: teal" valign="top" width="10">10&#160; </td>
<td width="569"><span style="color: #008000">&#160;&#160;&#160; </span><span style="color: #008000">&#160;</span><span style="color: #008000">&#160;</span><span style="color: #008000">&#160;</span><span style="color: #008000">&#160;</span><span style="color: #008000">textEl.focus();</span></td>
</tr>
<tr>
<td style="color: teal" valign="top" width="10">11&#160; </td>
<td width="569"><span style="color: #008000">&#160;&#160;&#160; </span><span style="color: #008000">&#160;</span><span style="color: #008000">&#160;</span><span style="color: #008000">&#160;</span><span style="color: #008000">&#160;</span><span style="color: #008000">document.selection.createRange().text</span><span style="color: #008000">&#160;</span><span style="color: #008000">=</span><span style="color: #008000">&#160;</span><span style="color: #008000">text;</span></td>
</tr>
<tr>
<td style="color: teal" valign="top" width="10">12&#160; </td>
<td width="569"><span style="color: #008000">&#160;&#160;&#160; </span><span style="color: #008000">&#160;</span><span style="color: #008000">&#160;</span><span style="color: #008000">&#160;</span><span style="color: #008000">&#160;</span><span style="color: #008000">@else</span><span style="color: #008000">&#160;</span><span style="color: #008000">@</span><span style="color: #008000">*/</span></td>
</tr>
<tr>
<td style="color: teal" valign="top" width="10">13&#160; </td>
<td width="569"><span style="color: #000000">&#160;&#160;&#160; </span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><b><span style="color: #0000ff">if</span></b><span style="color: #000000">&#160;</span><span style="color: #ff0000">(</span><span style="color: #000000">textEl</span><span style="color: #ff0000">.</span><span style="color: #000000">selectionStart</span><span style="color: #000000">&#160;</span><span style="color: #ff0000">|</span><span style="color: #ff0000">|</span><span style="color: #000000">&#160;</span><span style="color: #000000">textEl</span><span style="color: #ff0000">.</span><span style="color: #000000">selectionStart</span><span style="color: #000000">&#160;</span><span style="color: #ff0000">=</span><span style="color: #ff0000">=</span><span style="color: #000000">&#160;</span><span style="color: #ff0000">&#8216;</span><span style="color: #000000">0</span><span style="color: #ff0000">&#8216;</span><span style="color: #ff0000">)</span><span style="color: #000000">&#160;</span><span style="color: #000000">{</span></td>
</tr>
<tr>
<td style="color: teal" valign="top" width="10">14&#160; </td>
<td width="569"><span style="color: #000000">&#160;&#160;&#160; </span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><b><span style="color: #0000ff">var</span></b><span style="color: #000000">&#160;</span><span style="color: #000000">startPos</span><span style="color: #000000">&#160;</span><span style="color: #ff0000">=</span><span style="color: #000000">&#160;</span><span style="color: #000000">textEl</span><span style="color: #ff0000">.</span><span style="color: #000000">selectionStart</span><span style="color: #ff0000">;</span></td>
</tr>
<tr>
<td style="color: teal" valign="top" width="10">15&#160; </td>
<td width="569"><span style="color: #000000">&#160;&#160;&#160; </span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><b><span style="color: #0000ff">var</span></b><span style="color: #000000">&#160;</span><span style="color: #000000">endPos</span><span style="color: #000000">&#160;</span><span style="color: #ff0000">=</span><span style="color: #000000">&#160;</span><span style="color: #000000">textEl</span><span style="color: #ff0000">.</span><span style="color: #000000">selectionEnd</span><span style="color: #ff0000">;</span></td>
</tr>
<tr>
<td style="color: teal" valign="top" width="10">16&#160; </td>
<td width="569"><span style="color: #000000">&#160;&#160;&#160; </span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">textEl</span><span style="color: #ff0000">.</span><span style="color: #ff00ff">value</span><span style="color: #000000">&#160;</span><span style="color: #ff0000">=</span><span style="color: #000000">&#160;</span><span style="color: #000000">textEl</span><span style="color: #ff0000">.</span><span style="color: #ff00ff">value</span><span style="color: #ff0000">.</span><span style="color: #ff00ff">substring</span><span style="color: #ff0000">(</span><b><span style="color: #008080">0</span></b><span style="color: #ff0000">,</span><span style="color: #000000">&#160;</span><span style="color: #000000">startPos</span><span style="color: #ff0000">)</span></td>
</tr>
<tr>
<td style="color: teal" valign="top" width="10">17&#160; </td>
<td width="569"><span style="color: #000000">&#160;&#160;&#160; </span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #ff0000">+</span><span style="color: #000000">&#160;</span><span style="color: #ff00ff">text</span><span style="color: #000000">&#160;</span></td>
</tr>
<tr>
<td style="color: teal" valign="top" width="10">18&#160; </td>
<td width="569"><span style="color: #000000">&#160;&#160;&#160; </span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #ff0000">+</span><span style="color: #000000">&#160;</span><span style="color: #000000">textEl</span><span style="color: #ff0000">.</span><span style="color: #ff00ff">value</span><span style="color: #ff0000">.</span><span style="color: #ff00ff">substring</span><span style="color: #ff0000">(</span><span style="color: #000000">endPos</span><span style="color: #ff0000">,</span><span style="color: #000000">&#160;</span><span style="color: #000000">textEl</span><span style="color: #ff0000">.</span><span style="color: #ff00ff">value</span><span style="color: #ff0000">.</span><span style="color: #ff00ff">length</span><span style="color: #ff0000">)</span><span style="color: #ff0000">;</span></td>
</tr>
<tr>
<td style="color: teal" valign="top" width="10">19&#160; </td>
<td width="569"><span style="color: #000000">&#160;&#160;&#160; </span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">}</span><span style="color: #000000">&#160;</span><span style="color: #000000">else</span><span style="color: #000000">&#160;</span><span style="color: #000000">{</span></td>
</tr>
<tr>
<td style="color: teal" valign="top" width="10">20&#160; </td>
<td width="569"><span style="color: #000000">&#160;&#160;&#160; </span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">textEl</span><span style="color: #ff0000">.</span><span style="color: #ff00ff">value</span><span style="color: #000000">&#160;</span><span style="color: #ff0000">+</span><span style="color: #ff0000">=</span><span style="color: #000000">&#160;</span><span style="color: #ff00ff">text</span><span style="color: #ff0000">;</span></td>
</tr>
<tr>
<td style="color: teal" valign="top" width="10">21&#160; </td>
<td width="569"><span style="color: #000000">&#160;&#160;&#160; </span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">}</span></td>
</tr>
<tr>
<td style="color: teal" valign="top" width="10">22&#160; </td>
<td width="569"><span style="color: #000000">&#160;&#160;&#160; </span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">textEl</span><span style="color: #ff0000">.</span><span style="color: #000000">selectionStart</span><span style="color: #000000">&#160;</span><span style="color: #ff0000">=</span><span style="color: #000000">&#160;</span><span style="color: #000000">endPos</span><span style="color: #ff0000">+</span><b><span style="color: #008080">1</span></b><span style="color: #ff0000">;</span></td>
</tr>
<tr>
<td style="color: teal" valign="top" width="10">23&#160; </td>
<td width="569"><span style="color: #000000">&#160;&#160;&#160; </span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">textEl</span><span style="color: #ff0000">.</span><span style="color: #000000">selectionEnd</span><span style="color: #000000">&#160;</span><span style="color: #ff0000">=</span><span style="color: #000000">&#160;</span><span style="color: #000000">endPos</span><span style="color: #ff0000">+</span><b><span style="color: #008080">1</span></b><span style="color: #ff0000">;</span></td>
</tr>
<tr>
<td style="color: teal" valign="top" width="10">24&#160; </td>
<td width="569"><span style="color: #000000">&#160;&#160;&#160; </span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #008000">/*</span><span style="color: #008000">*/</span><span style="color: #008000">/*</span><span style="color: #008000">@end</span><span style="color: #008000">&#160;</span><span style="color: #008000">@</span><span style="color: #008000">*/</span></td>
</tr>
<tr>
<td style="color: teal" valign="top" width="10">25&#160; </td>
<td width="569"><span style="color: #000000">&#160;&#160;&#160; </span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><b><span style="color: #0000ff">return</span></b><span style="color: #000000">&#160;</span><b><span style="color: #0000ff">false</span></b><span style="color: #ff0000">;</span></td>
</tr>
<tr>
<td style="color: teal" valign="top" width="10">26&#160; </td>
<td width="569"><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #000000">&#160;</span><span style="color: #ff0000">}</span></td>
</tr>
<tr>
<td style="color: teal" valign="top" width="10">27&#160; </td>
<td width="569"><span style="color: #ff0000">}</span></td>
</tr>
</tbody>
</table></div>
<p>Line 3 :&#160; Tab键的keyCode值是9，这是根据键值判断输入是否是Tab键；</p>
<p>Line 22-23:&#160; 表示插入制表符后光标位于插入tab键后。</p>
]]></content:encoded>
			<wfw:commentRss>http://yaron.org.cn/archives/161/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>理理头绪——程序相关部分解读</title>
		<link>http://yaron.org.cn/archives/160</link>
		<comments>http://yaron.org.cn/archives/160#comments</comments>
		<pubDate>Fri, 13 Nov 2009 02:23:24 +0000</pubDate>
		<dc:creator>Yaron</dc:creator>
				<category><![CDATA[软件设计]]></category>

		<guid isPermaLink="false">http://yaron.org.cn/archives/160</guid>
		<description><![CDATA[&#160;&#160;&#160;&#160;&#160; 程序编写涉及到设计方法、语言环境、算法、数据结构等四个部分，其中设计方法、算法、数据结构，是编程的基础，也是学习的重中之重。
 
&#160;
程序设计方法：
&#160;&#160;&#160;&#160;&#160; 包括结构化程序设计，面向过程程序设计，面向对象程序设计，模块化程序设计，分布式程序设计，多层程序设计，XP极限程序设计等几种方法，它是编程的指导思想，决定了我们用什么样的方式组织编写程序，一个程序的成功与否完全由它决定；
语言和环境：
&#160;&#160;&#160;&#160;&#160; 编写程序的工具，程序由他们制造；这个应该是最容易掌握的部分；
算法：
&#160;&#160;&#160;&#160;&#160; 是灵魂，是解决问题（处理数据）的方法步骤（那设计模式也应该属于算法吧）；
数据结构：
&#160;&#160;&#160;&#160;&#160; 则是我们加工的对象，也是我们编写程序的根本目的————按照客户的需要加工，处理，传递它。
]]></description>
			<content:encoded><![CDATA[<p>&#160;&#160;&#160;&#160;&#160; 程序编写涉及到设计方法、语言环境、算法、数据结构等四个部分，其中设计方法、算法、数据结构，是编程的基础，也是学习的重中之重。</p>
<p> <span id="more-160"></span>
<p>&#160;</p>
<p><strong>程序设计方法：</strong></p>
<p>&#160;&#160;&#160;&#160;&#160; 包括结构化程序设计，面向过程程序设计，面向对象程序设计，模块化程序设计，分布式程序设计，多层程序设计，XP极限程序设计等几种方法，它是编程的指导思想，决定了我们用什么样的方式组织编写程序，一个程序的成功与否完全由它决定；</p>
<p><strong>语言和环境：</strong></p>
<p>&#160;&#160;&#160;&#160;&#160; 编写程序的工具，程序由他们制造；这个应该是最容易掌握的部分；</p>
<p><strong>算法：</strong></p>
<p>&#160;&#160;&#160;&#160;&#160; 是灵魂，是解决问题（处理数据）的方法步骤（那设计模式也应该属于算法吧）；</p>
<p><strong>数据结构：</strong></p>
<p>&#160;&#160;&#160;&#160;&#160; 则是我们加工的对象，也是我们编写程序的根本目的————按照客户的需要加工，处理，传递它。</p>
]]></content:encoded>
			<wfw:commentRss>http://yaron.org.cn/archives/160/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JS多语言设计方案</title>
		<link>http://yaron.org.cn/archives/157</link>
		<comments>http://yaron.org.cn/archives/157#comments</comments>
		<pubDate>Mon, 22 Jun 2009 12:54:30 +0000</pubDate>
		<dc:creator>Yaron</dc:creator>
				<category><![CDATA[JS脚本编程]]></category>

		<guid isPermaLink="false">http://yaron.org.cn/archives/157</guid>
		<description><![CDATA[&#160;&#160;&#160;&#160;&#160; 现在做一个多语言的应用系统，有涉及到JS的多语言设计方案。下午参照jquery的多语言插件，就写了一个简单的多语言设计方案。

&#160;&#160;&#160;&#160;&#160; 代码如下：

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
var message = &#123;&#125;;
var lang = 'zh';
&#160;
message.en=&#123;
	'year': 'year',
	'month': 'month',
	'day': 'day'
&#125;;
&#160;
message.zh=&#123;
	'year': '年',
	'month': '月',
	'day': '日'
&#125;;
&#160;
__ = function&#40;arg&#41;&#123;
	var msg_lang = eval&#40;'message.'+lang&#41;;
	if<a href="http://yaron.org.cn/archives/157" class="searchmore">Read the Rest...</a><div class="clr"></div>]]></description>
			<content:encoded><![CDATA[<p>&#160;&#160;&#160;&#160;&#160; 现在做一个多语言的应用系统，有涉及到JS的多语言设计方案。下午参照jquery的多语言插件，就写了一个简单的多语言设计方案。</p>
<p><span id="more-157"></span>
<p>&#160;&#160;&#160;&#160;&#160; 代码如下：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> message <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> lang <span style="color: #339933;">=</span> <span style="color: #3366CC;">'zh'</span><span style="color: #339933;">;</span>
&nbsp;
message.<span style="color: #660066;">en</span><span style="color: #339933;">=</span><span style="color: #009900;">&#123;</span>
	<span style="color: #3366CC;">'year'</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'year'</span><span style="color: #339933;">,</span>
	<span style="color: #3366CC;">'month'</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'month'</span><span style="color: #339933;">,</span>
	<span style="color: #3366CC;">'day'</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'day'</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
message.<span style="color: #660066;">zh</span><span style="color: #339933;">=</span><span style="color: #009900;">&#123;</span>
	<span style="color: #3366CC;">'year'</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'年'</span><span style="color: #339933;">,</span>
	<span style="color: #3366CC;">'month'</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'月'</span><span style="color: #339933;">,</span>
	<span style="color: #3366CC;">'day'</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'日'</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
__ <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>arg<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">var</span> msg_lang <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">eval</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'message.'</span><span style="color: #339933;">+</span>lang<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>arg <span style="color: #000066; font-weight: bold;">in</span> msg_lang<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">eval</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'msg_lang.'</span><span style="color: #339933;">+</span>arg<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>arg <span style="color: #000066; font-weight: bold;">in</span> message.<span style="color: #660066;">en</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">eval</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'message.en.'</span><span style="color: #339933;">+</span>arg<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #3366CC;">'Warning: &quot;'</span><span style="color: #339933;">+</span>arg<span style="color: #339933;">+</span><span style="color: #3366CC;">'&quot; is not in dictionary, Please add it!'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">//	alert(eval('message.'+lang+'.'+arg));</span>
<span style="color: #006600; font-style: italic;">//	return eval('message.'+lang+'.'+arg);</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://yaron.org.cn/archives/157/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
