<?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</title>
	<atom:link href="http://yaron.org.cn/feed" rel="self" type="application/rss+xml" />
	<link>http://yaron.org.cn</link>
	<description>About PHP MYSQL JS WEB FreeBSD etc.</description>
	<lastBuildDate>Tue, 05 Jan 2010 09:11:27 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>JS 知识点积累（持续更新）</title>
		<link>http://yaron.org.cn/archives/192</link>
		<comments>http://yaron.org.cn/archives/192#comments</comments>
		<pubDate>Tue, 05 Jan 2010 09:11:27 +0000</pubDate>
		<dc:creator>Yaron</dc:creator>
				<category><![CDATA[PHP功能类库]]></category>

		<guid isPermaLink="false">http://yaron.org.cn/archives/192</guid>
		<description><![CDATA[2010年1月5日
使用JS获得某容器下的对象


$(&#34;traccounts&#34;).getElementsByTagName(&#34;input&#34;)[0].value


在子窗口增加一条记录，添加成功后关闭子窗口，刷新父窗口


   1: opener.location.reload(); 

   2: window.close();


]]></description>
			<content:encoded><![CDATA[<h4>2010年1月5日</h4>
<h5>使用JS获得某容器下的对象</h5>
<div id="codeSnippetWrapper" style="border-right: silver 1px solid; padding-right: 4px; border-top: silver 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: silver 1px solid; width: 97.5%; cursor: text; direction: ltr; line-height: 12pt; padding-top: 4px; border-bottom: silver 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4; text-align: left; max-height: 200px">
<div id="codeSnippet" style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none">$(<span style="color: #006080">&quot;traccounts&quot;</span>).getElementsByTagName(<span style="color: #006080">&quot;input&quot;</span>)[0].value</pre>
<p><!--CRLF--></div>
</div>
<h5>在子窗口增加一条记录，添加成功后关闭子窗口，刷新父窗口</h5>
<div id="codeSnippetWrapper" style="border-right: silver 1px solid; padding-right: 4px; border-top: silver 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: silver 1px solid; width: 97.5%; cursor: text; direction: ltr; line-height: 12pt; padding-top: 4px; border-bottom: silver 1px solid; font-family: &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4; text-align: left; max-height: 200px">
<div id="codeSnippet" style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none">
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; text-align: left; border-bottom-style: none"><span id="lnum1" style="color: #606060">   1:</span> opener.location.reload(); </pre>
<p><!--CRLF--></p>
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; direction: ltr; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; text-align: left; border-bottom-style: none"><span id="lnum2" style="color: #606060">   2:</span> window.close();</pre>
<p><!--CRLF--></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://yaron.org.cn/archives/192/feed</wfw:commentRss>
		<slash:comments>1</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; 在Eclipse Xdebug调试中，查看$this-&#62;account_id 的值      $this     &#8211;varHolder     &#8212;-parameters     查看所有参数：     $this     &#8211;requestParameters
5&#160; 文件下载：




1&#160; [...]]]></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>2</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     &#160; param:&#160;&#160; { module: mediaplanning, action: showMediaPlanning }
 
在超链接中：    1. &#60;a href=&#34;&#60;?php echo url_for(&#34;@show_media_planning?media_planning_id={$media_planning-&#62;getId()}&#34;) ?&#62;&#34;&#62;xx&#60;/a&#62;     2. &#60;?php echo link_to(__(&#8217;Detail&#8217;, null, &#8216;navigation&#8217;),&#34;@show_media_planning?media_planning_id={$media_planning-&#62;getId()}&#34;)?&#62;
&#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;
创建数据库schema，symfony支持两种方式：一种是从编写schema.yml开始，然后用build-sql、insert-sql任务来创建表；另一种是反过来，先在MySQL中定义好表和关联，然后用build-schema来创建schema.yml。这两种方式是等效的，看个人的喜好而定。
1.0 [...]]]></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(__(&#8217;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(&#8217;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(&#8217;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(&#8217;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(&#8217;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>3</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; = $mccAccount['mobj'];     $mObj-&#62;setId(null);     $mObj-&#62;setSemUserId($uid);     $mObj-&#62;copyInto($mNewObj);     $mNewObj-&#62;save();     $mid&#160;&#160;&#160; = $mNewObj-&#62;getId();     $aNewObj&#160;&#160;&#160; = new [...]]]></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(&#8217;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(&#8217;Number&#8217;) ?&gt;     <br />&lt;?php $sf_user-&gt;setCulture(&#8217;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(&#8217;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(&#8217;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(&#8217;name&#8217;);     <br />&#160;&#160;&#160; &#8230;     <br />&#160;&#160;&#160; $this-&gt;redirect(&#8217;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(&#8217;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(&#8217;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(&#8217;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(&#8217;id&#8217;); ?&gt;     <br />| 简版:     <br />| &lt;?php echo $sf_params-&gt;get(&#8217;id&#8217;); ?&gt;     <br />|     <br />| 在动作(action)里面，相当于如下代码：     <br />| echo $this-&gt;getRequestParameter(&#8217;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(&#8217;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>4</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; 
&#160;&#160;&#160; &#160;&#160;&#160;&#160;@set&#160;@ie&#160;=&#160;true


9&#160; 
&#160;&#160;&#160; &#160;&#160;&#160;&#160;@if&#160;(@ie)


10&#160; 
&#160;&#160;&#160; &#160;&#160;&#160;&#160;textEl.focus();


11&#160; 
&#160;&#160;&#160; &#160;&#160;&#160;&#160;document.selection.createRange().text&#160;=&#160;text;


12&#160; 
&#160;&#160;&#160; &#160;&#160;&#160;&#160;@else&#160;@*/


13&#160; 
&#160;&#160;&#160; &#160;&#160;&#160;&#160;if&#160;(textEl.selectionStart&#160;&#124;&#124;&#160;textEl.selectionStart&#160;==&#160;&#8216;0&#8216;)&#160;{


14&#160; 
&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;var&#160;startPos&#160;=&#160;textEl.selectionStart;


15&#160; 
&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;var&#160;endPos&#160;=&#160;textEl.selectionEnd;


16&#160; 
&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;textEl.value&#160;=&#160;textEl.value.substring(0,&#160;startPos)


17&#160; 
&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;+&#160;text&#160;


18&#160; 
&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;+&#160;textEl.value.substring(endPos,&#160;textEl.value.length);


19&#160; 
&#160;&#160;&#160; &#160;&#160;&#160;&#160;}&#160;else&#160;{


20&#160; 
&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;textEl.value&#160;+=&#160;text;


21&#160; 
&#160;&#160;&#160; &#160;&#160;&#160;&#160;}


22&#160; 
&#160;&#160;&#160; &#160;&#160;&#160;&#160;textEl.selectionStart&#160;=&#160;endPos+1;


23&#160; 
&#160;&#160;&#160; &#160;&#160;&#160;&#160;textEl.selectionEnd&#160;=&#160;endPos+1;


24&#160; 
&#160;&#160;&#160; &#160;&#160;&#160;/**//*@end&#160;@*/


25&#160; 
&#160;&#160;&#160; [...]]]></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>2</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>1</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 &#40;arg in msg_lang&#41;&#123;
		return eval&#40;'msg_lang.'+arg&#41;;
	&#125;
&#160;
	if &#40;arg in message.en&#41; &#123;
		return eval&#40;'message.en.'+arg&#41;;
	&#125;
&#160;
	return 'Warning: &#34;'+arg+'&#34; is not in dictionary, Please add it!';
&#160;
//	alert(eval('message.'+lang+'.'+arg));
//	return eval('message.'+lang+'.'+arg);
&#160;
&#125;

]]></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>2</slash:comments>
		</item>
		<item>
		<title>Symfony 模版快捷变量应用实例</title>
		<link>http://yaron.org.cn/archives/156</link>
		<comments>http://yaron.org.cn/archives/156#comments</comments>
		<pubDate>Mon, 01 Jun 2009 11:18:55 +0000</pubDate>
		<dc:creator>Yaron</dc:creator>
				<category><![CDATA[Symfony]]></category>

		<guid isPermaLink="false">http://yaron.org.cn/archives/156</guid>
		<description><![CDATA[&#160;&#160;&#160;&#160;&#160; 在模版里，有一些Symfony变量可以直接使用。通过这些快捷变量可以从Symfony的对象中取得   一些最常用的模版信息：
 
$sf_context:&#160;&#160; 完整的环境对象(context object), sfContext类的实例   $sf_request:&#160; 请求对象，sfRequest类的实例    $sf_params:&#160;&#160; 请求的参数    $sf_user:&#160;&#160;&#160;&#160;&#160;&#160;&#160; 当前的用户session对象，sfUser类的实例    $sf_flash:&#160;&#160;&#160;&#160;&#160;&#160; 类似Session 一样的东西，不过只存储到下一个页面，就自动注销了。 
$sf_request 请求对象的实例： 
模版中获得请求的参数(http://www.a.cn/showpage.php?id=1，id就是请求showpage.php的参数)    &#124; &#60;?php echo $sf_request-&#62;getParameter(&#8217;id&#8217;); ?&#62;    &#124; 简版:    &#124; &#60;?php echo $sf_params-&#62;get(&#8217;id&#8217;); ?&#62;   [...]]]></description>
			<content:encoded><![CDATA[<p>&#160;&#160;&#160;&#160;&#160; 在模版里，有一些Symfony变量可以直接使用。通过这些快捷变量可以从Symfony的对象中取得   <br />一些最常用的模版信息：</p>
<p> <span id="more-156"></span>
<p>$sf_context:&#160;&#160; 完整的环境对象(context object), sfContext类的实例   <br />$sf_request:&#160; 请求对象，sfRequest类的实例    <br />$sf_params:&#160;&#160; 请求的参数    <br />$sf_user:&#160;&#160;&#160;&#160;&#160;&#160;&#160; 当前的用户session对象，sfUser类的实例    <br />$sf_flash:&#160;&#160;&#160;&#160;&#160;&#160; 类似Session 一样的东西，不过只存储到下一个页面，就自动注销了。 </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(&#8217;id&#8217;); ?&gt;    <br />| 简版:    <br />| &lt;?php echo $sf_params-&gt;get(&#8217;id&#8217;); ?&gt;    <br />|    <br />| 在动作(action)里面，相当于如下代码：    <br />| echo $this-&gt;getRequestParameter(&#8217;id&#8217;) </p>
<p>&#160;</p>
<h5>应用实例</h5>
<p><strong></strong>    <br /><strong>获得当前/最初访问的模块/动作名称     <br /></strong>&lt;?php     <br />$sf_last_module&#160; = $sf_context-&gt;getModuleName();    <br />$sf_last_action&#160; = $sf_context-&gt;getActionName();    <br />$sf_first_module = $sf_context-&gt;getActionStack()-&gt;getFirstEntry()-&gt;getModuleName();    <br />$sf_first_action = $sf_context-&gt;getActionStack()-&gt;getFirstEntry()-&gt;getActionName(); </p>
<p>$sf_context-&gt;getController()-&gt;getPresentationFor(&#8217;presentation&#8217;, &#8216;foo&#8217;);   <br />?&gt; </p>
<p><strong>扑捉错误：     <br /></strong>&lt;?php if ($sf_request-&gt;hasErrors()): ?&gt;    <br />&#160; &lt;h2&gt;Errors: &lt;/h2&gt;    <br />&#160;&#160;&#160; &lt;?php foreach ($sf_request-&gt;getErrorNames() as $name): ?&gt;    <br />&#160; &lt;dl&gt;    <br />&#160;&#160;&#160;&#160;&#160; &lt;dt&gt;&lt;?php echo $name ?&gt;&lt;/dt&gt;    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;dd&gt;&lt;?php echo $sf_request-&gt;getError($name) ?&gt;&lt;/dd&gt;    <br />&#160; &lt;/dl&gt;    <br />&#160;&#160;&#160; &lt;?php endforeach; ?&gt;    <br />&lt;?php elseif ($sf_flash-&gt;has(&#8217;notice&#8217;)): ?&gt;    <br />&lt;h2&gt;&lt;?php echo __($sf_flash-&gt;get(&#8217;notice&#8217;))&lt;/h2&gt;    <br />&lt;?php endif; ?&gt;</p>
]]></content:encoded>
			<wfw:commentRss>http://yaron.org.cn/archives/156/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>【转载】优秀的PHP程序员至少应该了解PHP代码的优缺点</title>
		<link>http://yaron.org.cn/archives/155</link>
		<comments>http://yaron.org.cn/archives/155#comments</comments>
		<pubDate>Mon, 01 Jun 2009 10:32:30 +0000</pubDate>
		<dc:creator>Yaron</dc:creator>
				<category><![CDATA[感悟/管理]]></category>

		<guid isPermaLink="false">http://yaron.org.cn/archives/155</guid>
		<description><![CDATA[&#160;&#160;&#160;&#160;&#160; 下午看到的一篇文章，受益匪浅。存档下来，时常温习。作者从代码的结构化、规范化、安全化、自适应四个方面，阐述了程序员必须得基本素质。虽然常有看到这样的文章，但是每每读到这样的文章，仍会发现自己的不足，每次阅读，都是一个敲打。
 
原文地址：http://news.csdn.net/n/20090107/122220.html
&#160;&#160;&#160;&#160;&#160; 我在SitePoint做面试官的时候一定会问的问题是：你认为PHP代码的优劣体现在哪里？因为这个问题可以让我大体知道应聘者是哪种类型的程序员，而不是单纯地考察他对PHP函数的掌握程度（这一点Zend的PHP认证做得不错，雅虎的PHP程序员面试题也属于此类）。重要的是，这个问题可以让我知道应聘者是否经历过这样的事情——从一个懒散程序员手中接过一段凌乱的代码进行重用，或者要帮助团队中的其他成员来处理这类事情。
&#160;&#160;&#160;&#160;&#160; 诚然，对于这个问题我自己也没有一个满意的答案，不过我知道哪些答案是我想听到的：
&#160;&#160;&#160;&#160;&#160; 优秀的PHP代码应该是结构化的。大段的代码应该被分割整理成一个个函数或方法，而那些不起眼的小段代码则应该加上注释，以便日后清楚它们的用途。而且应该尽可能地把前台代码如HTML、CSS、Javascript等从程序中分离出来。PHP的面向对象编程特性可以很好地帮助程序员将代码整理有序。
&#160;&#160;&#160;&#160;&#160; 优秀的PHP代码应该是规范化的。无论是为变量名和函数名设定命名规则，还是对一些会重复使用的过程如数据库操作和错误处理进行标准化，抑或是简单到规定好代码是怎样缩进的，这些规范化都可以让代码的可读性大大提高。
&#160;&#160;&#160;&#160;&#160; 优良的PHP代码应该是自适应的。PHP有许多特性如magic quotes和short tags，这些特性的打开和关闭会影响到程序的运行。所以，一个好的程序员应该在他的代码中加入适当的语句来使程序能够根据环境进行调整。
&#160;&#160;&#160;&#160;&#160; 优良的PHP代码应该是安全的。虽然PHP是一种高效、灵活的语言，没有固定的框架，但却把安全问题留给了程序员们。对潜在安全漏洞的深刻理解，如跨站脚本攻击（XSS）、跨站请求伪造（CSRF）、代码注入漏洞、字符编码循环漏洞等，对于今天的专业程序员来说是至关重要的。
&#160;&#160;&#160;&#160;&#160; 当应聘者在回答这些问题的时候，我就能清楚地知道是否该录用他。当然，有时程序员并不能很好地阐明这个问题，这时我们会让他们做一些PHP测试。测试中的许多问题表面上看起来非常简单，但这也给了应聘者们一个展现自我的机会，因为只要观察得仔细，就能找出问题。
&#160;&#160;&#160;&#160;&#160; 下面这一小段“劣质”的PHP代码是一道简化了的测试题。这种问题就像在问：你该怎样优化这段代码？

&#160;&#160;&#160;&#160;&#160; 这段代码的主要问题在于它把用户提交的数据直接显示到了网页上，从而产生XSS漏洞。其实有很多方法可以填补这个漏洞。那么，什么代码是我们想要的呢？

&#160;&#160;&#160;&#160;&#160; 这是最低要求。XSS漏洞用htmlspecialchars函数填补了，从而屏蔽了非法字符。

&#160;&#160;&#160;&#160;&#160; 能写出这样代码的人应该是我想要录用的人了：

&#160;&#160;&#160;&#160;&#160; 可惜的是，能给出这样让人满意答复的程序员少之又少。我们花了3个月的时间才招聘到让我们满意的程序员.
&#160;&#160;&#160;&#160;&#160; 那么，你会怎样回答文章开头提出的问题呢？你认为PHP代码的缺点体现在哪里？你认为一个PHP程序员还应具有哪些品质？
&#160;
注：
&#160;&#160;&#160;&#160;&#160; 时常在想，每次阅读这样的文章，就是和作者的一次交流。常和高级程序工程师交流，水平一定能有很好的提升。站在巨人的肩膀上！谢谢这些未名的巨人。
]]></description>
			<content:encoded><![CDATA[<p>&#160;&#160;&#160;&#160;&#160; 下午看到的一篇文章，受益匪浅。存档下来，时常温习。作者从代码的结构化、规范化、安全化、自适应四个方面，阐述了程序员必须得基本素质。虽然常有看到这样的文章，但是每每读到这样的文章，仍会发现自己的不足，每次阅读，都是一个敲打。</p>
<p> <span id="more-155"></span>
<p>原文地址：<a title="http://news.csdn.net/n/20090107/122220.html" href="http://news.csdn.net/n/20090107/122220.html">http://news.csdn.net/n/20090107/122220.html</a></p>
<p>&#160;&#160;&#160;&#160;&#160; 我在SitePoint做面试官的时候一定会问的问题是：你认为PHP代码的优劣体现在哪里？因为这个问题可以让我大体知道应聘者是哪种类型的程序员，而不是单纯地考察他对PHP函数的掌握程度（这一点Zend的PHP认证做得不错，雅虎的PHP程序员面试题也属于此类）。重要的是，这个问题可以让我知道应聘者是否经历过这样的事情——从一个懒散程序员手中接过一段凌乱的代码进行重用，或者要帮助团队中的其他成员来处理这类事情。</p>
<p>&#160;&#160;&#160;&#160;&#160; 诚然，对于这个问题我自己也没有一个满意的答案，不过我知道哪些答案是我想听到的：</p>
<p>&#160;&#160;&#160;&#160;&#160; <strong>优秀的PHP代码应该是结构化的。</strong>大段的代码应该被分割整理成一个个函数或方法，而那些不起眼的小段代码则应该加上注释，以便日后清楚它们的用途。而且应该尽可能地把前台代码如HTML、CSS、Javascript等从程序中分离出来。PHP的面向对象编程特性可以很好地帮助程序员将代码整理有序。</p>
<p>&#160;&#160;&#160;&#160;&#160; <strong>优秀的PHP代码应该是规范化的。</strong>无论是为变量名和函数名设定命名规则，还是对一些会重复使用的过程如数据库操作和错误处理进行标准化，抑或是简单到规定好代码是怎样缩进的，这些规范化都可以让代码的可读性大大提高。</p>
<p>&#160;&#160;&#160;&#160;&#160; <strong>优良的PHP代码应该是自适应的。</strong>PHP有许多特性如magic quotes和short tags，这些特性的打开和关闭会影响到程序的运行。所以，一个好的程序员应该在他的代码中加入适当的语句来使程序能够根据环境进行调整。</p>
<p>&#160;&#160;&#160;&#160;&#160; <strong>优良的PHP代码应该是安全的。</strong>虽然PHP是一种高效、灵活的语言，没有固定的框架，但却把安全问题留给了程序员们。对潜在安全漏洞的深刻理解，如跨站脚本攻击（XSS）、跨站请求伪造（CSRF）、代码注入漏洞、字符编码循环漏洞等，对于今天的专业程序员来说是至关重要的。</p>
<p>&#160;&#160;&#160;&#160;&#160; 当应聘者在回答这些问题的时候，我就能清楚地知道是否该录用他。当然，有时程序员并不能很好地阐明这个问题，这时我们会让他们做一些PHP测试。测试中的许多问题表面上看起来非常简单，但这也给了应聘者们一个展现自我的机会，因为只要观察得仔细，就能找出问题。</p>
<p>&#160;&#160;&#160;&#160;&#160; 下面这一小段“劣质”的PHP代码是一道简化了的测试题。这种问题就像在问：你该怎样优化这段代码？</p>
<p><img alt="" src="http://info-database.csdn.net/Upload/2009-01-07/%7BBC286E48-1C9A-4ABB-8A05-22FDBC576C47%7D.jpg" /></p>
<p>&#160;&#160;&#160;&#160;&#160; 这段代码的主要问题在于它把用户提交的数据直接显示到了网页上，从而产生XSS漏洞。其实有很多方法可以填补这个漏洞。那么，什么代码是我们想要的呢？</p>
<p><img alt="" src="http://info-database.csdn.net/Upload/2009-01-07/%7BE6D3AE21-3CA4-4C8E-AC80-13206D9261BB%7D.jpg" /></p>
<p>&#160;&#160;&#160;&#160;&#160; 这是最低要求。XSS漏洞用htmlspecialchars函数填补了，从而屏蔽了非法字符。</p>
<p><img alt="" src="http://info-database.csdn.net/Upload/2009-01-07/%7B4AF61A27-803D-43B7-80CC-2DFD16C6C45D%7D.jpg" /></p>
<p>&#160;&#160;&#160;&#160;&#160; 能写出这样代码的人应该是我想要录用的人了：</p>
<p><img alt="" src="http://info-database.csdn.net/Upload/2009-01-07/%7BB53104E9-63C6-4C89-A73E-3B628E1B9C52%7D.jpg" /></p>
<p>&#160;&#160;&#160;&#160;&#160; 可惜的是，能给出这样让人满意答复的程序员少之又少。我们花了3个月的时间才招聘到让我们满意的程序员.</p>
<p>&#160;&#160;&#160;&#160;&#160; 那么，你会怎样回答文章开头提出的问题呢？你认为PHP代码的缺点体现在哪里？你认为一个PHP程序员还应具有哪些品质？</p>
<p>&#160;</p>
<p>注：</p>
<p>&#160;&#160;&#160;&#160;&#160; 时常在想，每次阅读这样的文章，就是和作者的一次交流。常和高级程序工程师交流，水平一定能有很好的提升。站在巨人的肩膀上！谢谢这些未名的巨人。</p>
]]></content:encoded>
			<wfw:commentRss>http://yaron.org.cn/archives/155/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Symfony 自动生成后台程序</title>
		<link>http://yaron.org.cn/archives/153</link>
		<comments>http://yaron.org.cn/archives/153#comments</comments>
		<pubDate>Mon, 01 Jun 2009 09:46:38 +0000</pubDate>
		<dc:creator>Yaron</dc:creator>
				<category><![CDATA[Symfony]]></category>

		<guid isPermaLink="false">http://yaron.org.cn/archives/153</guid>
		<description><![CDATA[&#160;&#160;&#160;&#160;&#160; 使用Symfony框架自身提供的后台生成器，对写后台来说，是很大的福音。它减缩了很多工作，让注意力放到了逻辑设计上。下面是主要流程：
 
&#160;

建立后台程序/管理模块
创建生成后台程序的配置文件
增加登陆模块 

* 建立后台程序/管理模块
&#62; symfony init-app backend    &#62; symfony propel-init-admin backend post Post    &#62; symfony propel-init-admin backend comment Comment 
注意：生成管理模块与创建一般模块不同，一般模块init-module，而管理模块propel-init-admin.   其实这个与脚手架的创建类似：    &#160;&#160;&#160; symfony propel-generate-crud frontend post Post    &#160;&#160;&#160; symfony propel-generate-crud frontend comment Comment 
* 创建生成后台程序的配置文件
配置文件位置：/apps/backend/modules/moduleName/config/generator.yml    具体配置信息请参考 Symfony [...]]]></description>
			<content:encoded><![CDATA[<p>&#160;&#160;&#160;&#160;&#160; 使用Symfony框架自身提供的后台生成器，对写后台来说，是很大的福音。它减缩了很多工作，让注意力放到了逻辑设计上。下面是主要流程：</p>
<p> <span id="more-153"></span>
<p>&#160;</p>
<ul>
<li>建立后台程序/管理模块</li>
<li>创建生成后台程序的配置文件</li>
<li>增加登陆模块 </li>
</ul>
<h4>* 建立后台程序/管理模块</h4>
<p>&gt; symfony init-app backend    <br />&gt; symfony propel-init-admin backend post Post    <br />&gt; symfony propel-init-admin backend comment Comment </p>
<p>注意：生成管理模块与创建一般模块不同，一般模块init-module，而管理模块propel-init-admin.   <br />其实这个与脚手架的创建类似：    <br />&#160;&#160;&#160; symfony propel-generate-crud frontend post Post    <br />&#160;&#160;&#160; symfony propel-generate-crud frontend comment Comment </p>
<h4>* 创建生成后台程序的配置文件</h4>
<p>配置文件位置：/apps/backend/modules/moduleName/config/generator.yml    <br />具体配置信息请参考 Symfony 权威指南14章。 </p>
<h4>* 增加登陆模块</h4>
<p>&gt; symfony init-module backend security    <br />编辑apps/backend/modules/post/config/security.yml    <br />all:    <br />&#8211;is_secure: on </p>
<p>在文件apps/backend/modules/security/templates/indexSuccess.php中，增加登陆表单。   <br />在文件apps/backend/modules/security/actions/actions.class.php中，增加login方法。    <br />在文件apps/backend/config/settings.yml中，设置登陆模块：    <br />all:    <br />&#160; .actions:    <br />&#160;&#160;&#160;&#160;&#160; login_module:&#160;&#160;&#160;&#160; security    <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; login_action:&#160;&#160;&#160;&#160; index </p>
<p>That is All! </p>
]]></content:encoded>
			<wfw:commentRss>http://yaron.org.cn/archives/153/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>
