<?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>eKini Web Developer Blog</title>
	<atom:link href="http://blog.ekini.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.ekini.net</link>
	<description>Wenbert Del Rosario: PHP, MySQL, Javascript, MVC, Zend Framework, AJAX, jQuery.</description>
	<lastBuildDate>Sun, 14 Mar 2010 09:24:02 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>A CSV File and SQL Dump for all the zip codes in Philippines</title>
		<link>http://blog.ekini.net/2010/03/14/a-csv-file-and-sql-dump-for-all-the-zip-codes-in-philippines/</link>
		<comments>http://blog.ekini.net/2010/03/14/a-csv-file-and-sql-dump-for-all-the-zip-codes-in-philippines/#comments</comments>
		<pubDate>Sun, 14 Mar 2010 09:23:02 +0000</pubDate>
		<dc:creator>Wenbert</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[philippines zipcode]]></category>
		<category><![CDATA[zip codes]]></category>
		<category><![CDATA[zipcode]]></category>

		<guid isPermaLink="false">http://blog.ekini.net/?p=713</guid>
		<description><![CDATA[I spent a few hours yesterday gathering all the zip codes for the Philippines. This is public data, so I am sharing it with everyone. If you use it, I&#8217;d appreciate it if you credit me (It is not required but it would be great if you can send some traffic to my site &#8212; [...]]]></description>
			<content:encoded><![CDATA[<p>I spent a few hours yesterday gathering all the zip codes for the Philippines. This is public data, so I am sharing it with everyone. If you use it, I&#8217;d appreciate it if you credit me (It is not required but it would be great if you can send some traffic to my site &#8212; I have been planning to get a <a href="http://www.linode.com/">Linode </a>but I can&#8217;t afford one yet :P).</p>
<p>Here is a preview of the CSV file:</p>
<pre>
"id","country","major_area","zip_code","city"
"1","PH","Abra","2800","Bangued"
"2","PH","Abra","2801","Dolores"
"3","PH","Abra","2802","Lagangilang"
"4","PH","Abra","2803","Tayum"
"5","PH","Abra","2804","Peñarrubia"
"6","PH","Abra","2805","Bucay"
"7","PH","Abra","2806","Pidigan"
"8","PH","Abra","2807","Langiden"
"9","PH","Abra","2808","San Quintin"
"10","PH","Abra","2809","San Isidro"
"11","PH","Abra","2810","Manabo"
"12","PH","Abra","2811","Villaviciosa"
"13","PH","Abra","2812","Pilar"
"14","PH","Abra","2813","Luba"
...
...
...
"462","PH","Cebu","6000","Cebu City"
"463","PH","Cebu","6003","Compostela"
"464","PH","Cebu","6001","Consolacion"
"465","PH","Cebu","6017","Cordova"
"466","PH","Cebu","6013","Daanbantayan"
"467","PH","Cebu","6022","Dalaguete"
"468","PH","Cebu","6004","Danao City"
"469","PH","Cebu","6035","Dumanjug"
"470","PH","Cebu","6028","Ginatilan"
"471","PH","Cebu","6015","Lapu-Lapu City (Opon)"
"472","PH","Cebu","6002","Liloan"
"473","PH","Cebu","6016","Mactan Airport"
</pre>
<p>The MySQL Table is like this:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #993333; font-weight: bold;">IF</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">EXISTS</span> <span style="color: #ff0000;">`zipcodes`</span> <span style="color: #66cc66;">&#40;</span>
  <span style="color: #ff0000;">`id`</span> int<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">11</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">AUTO_INCREMENT</span><span style="color: #66cc66;">,</span>
  <span style="color: #ff0000;">`country`</span> char<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
  <span style="color: #ff0000;">`major_area`</span> varchar<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">300</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
  <span style="color: #ff0000;">`zip_code`</span> varchar<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">25</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
  <span style="color: #ff0000;">`city`</span> varchar<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">300</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
  <span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">`id`</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
  <span style="color: #993333; font-weight: bold;">KEY</span> <span style="color: #ff0000;">`major_area`</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">`major_area`</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
  <span style="color: #993333; font-weight: bold;">KEY</span> <span style="color: #ff0000;">`zip_code`</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">`zip_code`</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span>
  <span style="color: #993333; font-weight: bold;">KEY</span> <span style="color: #ff0000;">`city`</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">`city`</span><span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#41;</span> ENGINE<span style="color: #66cc66;">=</span>MyISAM</pre></div></div>

<p>Updated: <em>March 13, 2010 (2,270 zip codes)</em></p>
<p><strong>Download the files below:</strong></p>
<ul>
<li><a href="http://ekini.net/ph_zipcodes.csv">CSV File</a></li>
<li><a href="http://ekini.net/ph_zipcodes.sql">MySQL Dump File</a></li>
</ul>
<p>Corrections, suggestions, etc. just leave a comment below.</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ekini.net/2010/03/14/a-csv-file-and-sql-dump-for-all-the-zip-codes-in-philippines/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CSS: Creating a horizontal menu/navigation bar</title>
		<link>http://blog.ekini.net/2010/03/10/css-creating-a-horizontal-menunavigation-bar/</link>
		<comments>http://blog.ekini.net/2010/03/10/css-creating-a-horizontal-menunavigation-bar/#comments</comments>
		<pubDate>Wed, 10 Mar 2010 08:22:29 +0000</pubDate>
		<dc:creator>Wenbert</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[horizontal menu]]></category>
		<category><![CDATA[horizontal navigation bar]]></category>

		<guid isPermaLink="false">http://blog.ekini.net/?p=711</guid>
		<description><![CDATA[I always forget how to do this. Every time I forget, it takes me about 10minutes searching for the right one. So I am posting it here for my reference.
My HTML would look something like this:

&#60;div id=&#34;navbar&#34;&#62;
    &#60;ul&#62;
        &#60;li class=&#34;first&#34;&#62;&#60;a href=&#34;#&#34;&#62;Home&#60;/a&#62;&#60;/li&#62;
     [...]]]></description>
			<content:encoded><![CDATA[<p>I always forget how to do this. Every time I forget, it takes me about 10minutes searching for the right one. So I am posting it here for my reference.</p>
<p>My HTML would look something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;div id=&quot;navbar&quot;&gt;
    &lt;ul&gt;
        &lt;li class=&quot;first&quot;&gt;&lt;a href=&quot;#&quot;&gt;Home&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#&quot;&gt;About&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Services&lt;/a&gt;&lt;/li&gt;
        &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Projects&lt;/a&gt;&lt;/li&gt;
        &lt;li class=&quot;last&quot;&gt;&lt;a href=&quot;#&quot;&gt;Contact&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
&lt;/div&gt;</pre></div></div>

<p>And my CSS would look something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#navbar</span> <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#d90000</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#navbar</span> ul <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> 
    <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#navbar</span> ul li <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">inline</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">list-style-type</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">padding-right</span><span style="color: #00AA00;">:</span> <span style="color: #933;">20px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#navbar</span> ul li a<span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span> 
    <span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">white</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">10.5px</span> <span style="color: #933;">11px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#navbar</span> ul li a<span style="color: #3333ff;">:visited </span><span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">white</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#navbar</span> ul li a<span style="color: #3333ff;">:hover</span><span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#navbar</span> ul li .current<span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#bf0000</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#navbar</span> <span style="color: #6666ff;">.first</span>  <span style="color: #00AA00;">&#123;</span>
    <span style="color: #808080; font-style: italic;">/*You can put stuff here for the first item in the navbar*/</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#navbar</span> <span style="color: #6666ff;">.last</span>  <span style="color: #00AA00;">&#123;</span>
    <span style="color: #808080; font-style: italic;">/*You can put stuff here for the last item in the navbar*/</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>Comments or suggestions please ;-)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ekini.net/2010/03/10/css-creating-a-horizontal-menunavigation-bar/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Zend Framework: How to use nested transactions with Zend_Db and MySQL</title>
		<link>http://blog.ekini.net/2010/03/05/zend-framework-how-to-use-nested-transactions-with-zend_db-and-mysql/</link>
		<comments>http://blog.ekini.net/2010/03/05/zend-framework-how-to-use-nested-transactions-with-zend_db-and-mysql/#comments</comments>
		<pubDate>Fri, 05 Mar 2010 13:51:40 +0000</pubDate>
		<dc:creator>Wenbert</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[database transactions]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[transactions]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[Zend_Db]]></category>

		<guid isPermaLink="false">http://blog.ekini.net/?p=707</guid>
		<description><![CDATA[Steve Hollis first blog post about practical nested database transactions using Zend_Db. He writes really well and his blog is very readable. I love reading long text in Serif :D Thanks Steve!
His solution:
The Solution
Disclaimer: This solution is adapted from the extended Pdo_MySql adapter in Varien’s Magento e-commerce product. A similar approach is adopted by Bryce [...]]]></description>
			<content:encoded><![CDATA[<p><a href="stevehollis.com">Steve Hollis</a> first blog post about practical nested database transactions using Zend_Db. He writes really well and his blog is very readable. I love reading long text in Serif :D Thanks Steve!</p>
<p>His solution:</p>
<blockquote><p>The Solution<br />
Disclaimer: This solution is adapted from the extended Pdo_MySql adapter in Varien’s Magento e-commerce product. A similar approach is adopted by Bryce Lohr’s Nested Table Support for Zend_Db proposal. You should read Bill Karwin’s comments about that proposal and understand the limitations of this method before implementing it. That said, I still believe this is a useful and practical way of simulating nested transactions and I have used it a number of times.</p>
<p>A simple solution to the problem is to keep track of the “depth” of the transaction, that is, how many times the beginTransaction() method has been called. That way, we can hold off committing the changes to the database until we are certain that all the save operations have completed successfully.</p>
<p>Since transactions apply to the whole database connection, the most logical place to manage this process is in the DB adapter class. To do this, we extend our adapter class like so:</p></blockquote>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">App_Zend_Db_Adapter_Mysqli <span style="color: #000000; font-weight: bold;">extends</span> Zend_Db_Adapter_Mysqli
<span style="color: #009900;">&#123;</span>
    <span style="color: #009933; font-style: italic;">/**
     * Current Transaction Level
     *
     * @var int
     */</span>
    protected <span style="color: #000088;">$_transactionLevel</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * Begin new DB transaction for connection
     *
     * @return App_Zend_Db_Adapter_Mysqli
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> beginTransaction<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_transactionLevel <span style="color: #339933;">===</span> <span style="color: #cc66cc;">0</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            parent<span style="color: #339933;">::</span><span style="color: #004000;">beginTransaction</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_transactionLevel<span style="color: #339933;">++;</span>
&nbsp;
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * Commit DB transaction
     *
     * @return App_Zend_Db_Adapter_Mysqli
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> commit<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_transactionLevel <span style="color: #339933;">===</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            parent<span style="color: #339933;">::</span><span style="color: #004000;">commit</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_transactionLevel<span style="color: #339933;">--;</span>
&nbsp;
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * Rollback DB transaction
     *
     * @return App_Zend_Db_Adapter_Mysqli
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> rollback<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_transactionLevel <span style="color: #339933;">===</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            parent<span style="color: #339933;">::</span><span style="color: #004000;">rollback</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_transactionLevel<span style="color: #339933;">--;</span>
&nbsp;
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * Get adapter transaction level state. Return 0 if all transactions are complete
     *
     * @return int
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getTransactionLevel<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_transactionLevel<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<blockquote><p>Update your bootstrap to use the extended class et voila – a single START TRANSACTION and COMMIT or ROLLBACK is sent to MySQL, regardless of how many levels of nested pseudo-transactions have been created.</p>
<p>Please Note:</p>
<ol>
<li>It’s important that each child save() method re-throws the exception so that transaction depth is reduced by successive calls to rollBack(). The end result is that the originally called save() method then performs the actual rollback.
</li>
<li>
All the tables used in the transaction must use a storage engine that supports transactions. For MySQL, this will most likely mean using InnoDB. To convert a MyISAM or other table type to InnoDB, use “ALTER TABLE table ENGINE = InnoDB”. It could take some time to rebuild the indexes on large tables. There are other considerations about the use of InnoDB – please consult the MySQL manual.
</li>
<li>
If the tables used don’t support transactions, it’ll just fail silently. Bad times. I highly recommend using Firebug and Zend_Db_Profiler to monitor database queries during development (see http://framework.zend.com/manual/en/zend.db.profiler.html);
</li>
</ol>
</blockquote>
<p>And of course, the source can be found here: <a href="http://www.stevehollis.com/2010/03/practical-nested-transactions-with-zend_db-and-mysql/">http://www.stevehollis.com/2010/03/practical-nested-transactions-with-zend_db-and-mysql/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ekini.net/2010/03/05/zend-framework-how-to-use-nested-transactions-with-zend_db-and-mysql/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Zend Framework: Using Command Line Scripts</title>
		<link>http://blog.ekini.net/2010/02/25/zend-framework-using-command-line-scripts/</link>
		<comments>http://blog.ekini.net/2010/02/25/zend-framework-using-command-line-scripts/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 07:18:21 +0000</pubDate>
		<dc:creator>Wenbert</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[bootstrap]]></category>
		<category><![CDATA[cli]]></category>
		<category><![CDATA[command line scripts]]></category>
		<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://blog.ekini.net/2010/02/25/zend-framework-using-command-line-scripts/</guid>
		<description><![CDATA[Thanks to David Caunt for this very useful article.
The article shows us how to create command line scripts using Zend Framework components. This is very useful especially with the database stuff.

&#60;?php
&#160;
// Define path to application directory
defined&#40;'APPLICATION_PATH'&#41;
    &#124;&#124; define&#40;'APPLICATION_PATH',
              realpath&#40;dirname&#40;__FILE__&#41; [...]]]></description>
			<content:encoded><![CDATA[<p>Thanks to <a href="http://www.davidcaunt.co.uk/2010/02/25/easy-command-line-scripts-with-zend-application/">David Caunt</a> for this very useful article.</p>
<p>The article shows us how to create command line scripts using Zend Framework components. This is very useful especially with the database stuff.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Define path to application directory</span>
<span style="color: #990000;">defined</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'APPLICATION_PATH'</span><span style="color: #009900;">&#41;</span>
    <span style="color: #339933;">||</span> <span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'APPLICATION_PATH'</span><span style="color: #339933;">,</span>
              <span style="color: #990000;">realpath</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">dirname</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/../application'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Define application environment</span>
<span style="color: #990000;">defined</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'APPLICATION_ENV'</span><span style="color: #009900;">&#41;</span>
    <span style="color: #339933;">||</span> <span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'APPLICATION_ENV'</span><span style="color: #339933;">,</span>
              <span style="color: #009900;">&#40;</span><span style="color: #990000;">getenv</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'APPLICATION_ENV'</span><span style="color: #009900;">&#41;</span> ? <span style="color: #990000;">getenv</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'APPLICATION_ENV'</span><span style="color: #009900;">&#41;</span>
                                         <span style="color: #339933;">:</span> <span style="color: #0000ff;">'production'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">require_once</span> <span style="color: #0000ff;">'Zend/Application.php'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$application</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Application<span style="color: #009900;">&#40;</span>
    APPLICATION_ENV<span style="color: #339933;">,</span>
    APPLICATION_PATH <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/configs/config.php'</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//only load resources we need for script, in this case db and mail</span>
<span style="color: #000088;">$application</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">bootstrap</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'db'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'mail'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Using it would be something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$db</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$application</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getBootstrap</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getResource</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'db'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//do something!</span>
<span style="color: #000088;">$row</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fetchRow</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'SELECT * FROM something'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The source can be found <a href="http://www.davidcaunt.co.uk/2010/02/25/easy-command-line-scripts-with-zend-application/">here</a>. Sorry for the copy-paste. This is so useful that I want to see the code every time I forget.</p>
<p>Thanks to <a href="http://www.zendframeworkinaction.com/2010/02/25/writing-command-line-scripts-for-your-zf-application/">Rob Allen</a> for directing me to <a href="http://www.davidcaunt.co.uk">David Caunt</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ekini.net/2010/02/25/zend-framework-using-command-line-scripts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Unit Test your Zend Framework Application</title>
		<link>http://blog.ekini.net/2010/02/17/learning-unit-testing-with-zend-frameworking/</link>
		<comments>http://blog.ekini.net/2010/02/17/learning-unit-testing-with-zend-frameworking/#comments</comments>
		<pubDate>Wed, 17 Feb 2010 15:00:12 +0000</pubDate>
		<dc:creator>Wenbert</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[phpunit]]></category>
		<category><![CDATA[unit testing]]></category>
		<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://blog.ekini.net/?p=697</guid>
		<description><![CDATA[I am trying to learn Unit Testing using Zend Framework. I have set up a test application called LyZend in Github. Supposedly, the application should be able to display artists, albums, and tracks.
The tests are found in: http://github.com/wenbert/lyzend/tree/master/tests/ I have follwed Matthew Weier O&#8217;phinney&#8217;s method of setting up the tests. 
lyzend / tests / TestHelper.php

&#60;?php
require_once [...]]]></description>
			<content:encoded><![CDATA[<p>I am trying to learn Unit Testing using Zend Framework. I have set up a test application called <a href="http://github.com/wenbert/lyzend">LyZend in Github</a>. Supposedly, the application should be able to display artists, albums, and tracks.</p>
<p>The tests are found in: <a href="http://github.com/wenbert/lyzend/tree/master/tests/">http://github.com/wenbert/lyzend/tree/master/tests/</a> I have follwed <a href="http://github.com/weierophinney/">Matthew Weier O&#8217;phinney&#8217;s</a> method of setting up the tests. </p>
<p><strong>lyzend / tests / TestHelper.php</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">require_once</span> <span style="color: #0000ff;">'TestConfig.php'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/*
 * Start output buffering
 */</span>
<span style="color: #990000;">ob_start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/*
 * Set error reporting to the level to which Zend Framework code must comply.
 */</span>
<span style="color: #990000;">error_reporting</span><span style="color: #009900;">&#40;</span> <span style="color: #009900; font-weight: bold;">E_ALL</span> <span style="color: #339933;">|</span> <span style="color: #009900; font-weight: bold;">E_STRICT</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/*
 * Set default timezone
 */</span>
<span style="color: #990000;">date_default_timezone_set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'GMT'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/*
 * Determine the root, library, tests, and models directories
 */</span>
<span style="color: #000088;">$root</span>        <span style="color: #339933;">=</span> <span style="color: #990000;">realpath</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">dirname</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/../'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$library</span>     <span style="color: #339933;">=</span> <span style="color: #000088;">$root</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/library'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$tests</span>       <span style="color: #339933;">=</span> <span style="color: #000088;">$root</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/tests'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$models</span>      <span style="color: #339933;">=</span> <span style="color: #000088;">$root</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/application/models'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$controllers</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$root</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/application/controllers'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/*
 * Prepend the library/, tests/, and models/ directories to the
 * include_path. This allows the tests to run out of the box.
 */</span>
<span style="color: #000088;">$path</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
    <span style="color: #000088;">$models</span><span style="color: #339933;">,</span>
    <span style="color: #000088;">$library</span><span style="color: #339933;">,</span>
    <span style="color: #000088;">$tests</span><span style="color: #339933;">,</span>
    <span style="color: #990000;">get_include_path</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">set_include_path</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">implode</span><span style="color: #009900;">&#40;</span>PATH_SEPARATOR<span style="color: #339933;">,</span> <span style="color: #000088;">$path</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Register autoloader
 */</span>
<span style="color: #b1b100;">require_once</span> <span style="color: #0000ff;">'Zend/Loader/Autoloader.php'</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//Zend_Loader::registerAutoload();</span>
Zend_Loader_Autoloader<span style="color: #339933;">::</span><span style="color: #004000;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/*
 * Add library/ and models/ directory to the PHPUnit code coverage
 * whitelist. This has the effect that only production code source files appear
 * in the code coverage report and that all production code source files, even
 * those that are not covered by a test yet, are processed.
 */</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">defined</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'TESTS_GENERATE_REPORT'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> TESTS_GENERATE_REPORT <span style="color: #339933;">===</span> <span style="color: #009900; font-weight: bold;">true</span> <span style="color: #339933;">&amp;&amp;</span>
    <span style="color: #990000;">version_compare</span><span style="color: #009900;">&#40;</span>PHPUnit_Runner_Version<span style="color: #339933;">::</span><span style="color: #004000;">id</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'3.1.6'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&gt;='</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    PHPUnit_Util_Filter<span style="color: #339933;">::</span><span style="color: #004000;">addDirectoryToWhitelist</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$library</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    PHPUnit_Util_Filter<span style="color: #339933;">::</span><span style="color: #004000;">addDirectoryToWhitelist</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$models</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    PHPUnit_Util_Filter<span style="color: #339933;">::</span><span style="color: #004000;">addDirectoryToWhitelist</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$controllers</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Setup default DB adapter
 */</span>
<span style="color: #666666; font-style: italic;">/*
$db = Zend_Db::factory('pdo_sqlite', array(
    'dbname' =&gt; $root . '/data/db/bugs.db',
));
Zend_Db_Table_Abstract::setDefaultAdapter($db);
*/</span>
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;">/*
 * Unset global variables that are no longer needed.
 */</span>
<span style="color: #990000;">unset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$root</span><span style="color: #339933;">,</span> <span style="color: #000088;">$library</span><span style="color: #339933;">,</span> <span style="color: #000088;">$models</span><span style="color: #339933;">,</span> <span style="color: #000088;">$controllers</span><span style="color: #339933;">,</span> <span style="color: #000088;">$tests</span><span style="color: #339933;">,</span> <span style="color: #000088;">$path</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>You might noticed that I included a <strong>TestConfig.php</strong> file above. Here is the file:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Define path to application directory</span>
<span style="color: #990000;">defined</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'APPLICATION_PATH'</span><span style="color: #009900;">&#41;</span>
    <span style="color: #339933;">||</span> <span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'APPLICATION_PATH'</span><span style="color: #339933;">,</span> <span style="color: #990000;">realpath</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">dirname</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/../application'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Define application environment</span>
<span style="color: #990000;">defined</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'APPLICATION_ENV'</span><span style="color: #009900;">&#41;</span>
    <span style="color: #339933;">||</span> <span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'APPLICATION_ENV'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">getenv</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'APPLICATION_ENV'</span><span style="color: #009900;">&#41;</span> ? <span style="color: #990000;">getenv</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'APPLICATION_ENV'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">'testing'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Ensure library/ is on include_path</span>
<span style="color: #990000;">set_include_path</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">implode</span><span style="color: #009900;">&#40;</span>PATH_SEPARATOR<span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
    <span style="color: #990000;">realpath</span><span style="color: #009900;">&#40;</span>APPLICATION_PATH <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/../library'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
    <span style="color: #990000;">get_include_path</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Here is a sample test for my Artist Model.<br />
<strong>lyzend / tests / application / models / ArtistTest.php</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">// Call Model_ArtistTest::main() if this source file is executed directly.</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">defined</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;PHPUnit_MAIN_METHOD&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;PHPUnit_MAIN_METHOD&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;Model_ArtistTest::main&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">require_once</span> <span style="color: #990000;">dirname</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/../../TestHelper.php'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/** Model_Artist */</span>
<span style="color: #b1b100;">require_once</span> <span style="color: #0000ff;">'Artist.php'</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">require_once</span> <span style="color: #0000ff;">'ArtistMapper.php'</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">require_once</span> <span style="color: #0000ff;">'DbTable/Artist.php'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Test class for Model_Artist.
 *
 * @group Models
 */</span>
<span style="color: #000000; font-weight: bold;">class</span> Model_ArtistTest <span style="color: #000000; font-weight: bold;">extends</span> Zend_Test_PHPUnit_ControllerTestCase 
<span style="color: #009900;">&#123;</span>
    <span style="color: #009933; font-style: italic;">/**
     * Runs the test methods of this class.
     *
     * @return void
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> static <span style="color: #000000; font-weight: bold;">function</span> main<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$suite</span>  <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> PHPUnit_Framework_TestSuite<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Model_ArtistTest&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> PHPUnit_TextUI_TestRunner<span style="color: #339933;">::</span><span style="color: #004000;">run</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$suite</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * Sets up the fixture, for example, open a network connection.
     * This method is called before a test is executed.
     *
     * @return void
     */</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> setUp<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">bootstrap</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Application<span style="color: #009900;">&#40;</span>
            APPLICATION_ENV<span style="color: #339933;">,</span>
            APPLICATION_PATH <span style="color: #339933;">.</span> <span style="color: #009900; font-weight: bold;">DIRECTORY_SEPARATOR</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'configs'</span> <span style="color: #339933;">.</span> <span style="color: #009900; font-weight: bold;">DIRECTORY_SEPARATOR</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'application.ini'</span>
        <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        parent<span style="color: #339933;">::</span><span style="color: #004000;">setUp</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * Tears down the fixture, for example, close a network connection.
     * This method is called after a test is executed.
     *
     * @return void
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> tearDown<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> testCanTest<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">//this is a sample test</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The XML file is like this:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;phpunit<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;testsuite</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Ly Test Suite&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;directory<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>./<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/directory<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/testsuite<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;php<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #808080; font-style: italic;">&lt;!-- &lt;ini name=&quot;include_path&quot; value=&quot;../library&quot;/&gt; --&gt;</span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/php<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;filter<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;whitelist<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;directory</span> <span style="color: #000066;">suffix</span>=<span style="color: #ff0000;">&quot;.php&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>../library/<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/directory<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;directory</span> <span style="color: #000066;">suffix</span>=<span style="color: #ff0000;">&quot;.php&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>../application/<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/directory<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exclude<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;directory</span> <span style="color: #000066;">suffix</span>=<span style="color: #ff0000;">&quot;.phtml&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>../application/<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/directory<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;file<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>../application/Bootstrap.php<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/file<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;file<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>../application/controllers/ErrorController.php<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/file<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exclude<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/whitelist<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/filter<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;logging<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;log</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;coverage-html&quot;</span> <span style="color: #000066;">target</span>=<span style="color: #ff0000;">&quot;./log/report&quot;</span> <span style="color: #000066;">charset</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span></span>
<span style="color: #009900;">            <span style="color: #000066;">yui</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">highlight</span>=<span style="color: #ff0000;">&quot;true&quot;</span></span>
<span style="color: #009900;">            <span style="color: #000066;">lowUpperBound</span>=<span style="color: #ff0000;">&quot;50&quot;</span> <span style="color: #000066;">highLowerBound</span>=<span style="color: #ff0000;">&quot;80&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;log</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;testdox-html&quot;</span> <span style="color: #000066;">target</span>=<span style="color: #ff0000;">&quot;./log/testdox.html&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/logging<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/phpunit<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Running the test would be something like this:</p>
<pre>
phpunit --configuration phpunit.xml
</pre>
<p>Matthew did not provide sample test for Mappers. So I created one something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$mapper</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Ly_Model_ArtistMapper<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">assertTrue</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$mapper</span> instanceof Ly_Model_ArtistMapper<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><strong>My process was like:</strong></p>
<ol>
<li>Setup Unit Testing in Zend Framework</li>
<li>Create tests (let&#8217;s say for Artist Model).</li>
<li>Make code in my model to pass the tests.</li>
<li>Repeat step 2 and then go to next model if satisfied.</li>
</ol>
<p><strong>FYI:</strong> I am not so sure about my Model. I am not sure if I am breaking any rules when I created them. It would be cool if you could check them out (<a href="http://github.com/wenbert/lyzend/tree/master/application/models/">http://github.com/wenbert/lyzend/tree/master/application/models/</a>) and discuss my mistakes below.</p>
<p>Thanks!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ekini.net/2010/02/17/learning-unit-testing-with-zend-frameworking/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Akra&#8217;s Zend Framework 1.10 Tutorial</title>
		<link>http://blog.ekini.net/2010/02/08/akras-zend-framework-1-10-tutorial/</link>
		<comments>http://blog.ekini.net/2010/02/08/akras-zend-framework-1-10-tutorial/#comments</comments>
		<pubDate>Mon, 08 Feb 2010 09:37:28 +0000</pubDate>
		<dc:creator>Wenbert</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[akrabat]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://blog.ekini.net/?p=694</guid>
		<description><![CDATA[From Akrabat&#8217;s blog:
As a result, I have updated my Zend Framework tutorial so that it is completely current. The main change I made was to remove the _init methods in the Bootstrap as they are no longer needed. I also take advantage of the new features of the zf tool to enable layouts and create [...]]]></description>
			<content:encoded><![CDATA[<p>From Akrabat&#8217;s blog:</p>
<blockquote><p>As a result, I have updated my <a href="http://akrabat.com/zend-framework-tutorial/">Zend Framework tutorial</a> so that it is completely current. The main change I made was to remove the _init methods in the Bootstrap as they are no longer needed. I also take advantage of the new features of the zf tool to enable layouts and create forms. It&#8217;s a shame that it gets the class name of the form wrong though!</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://blog.ekini.net/2010/02/08/akras-zend-framework-1-10-tutorial/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTML5 Canvas Tutorial</title>
		<link>http://blog.ekini.net/2010/02/08/html5-canvas-tutorial/</link>
		<comments>http://blog.ekini.net/2010/02/08/html5-canvas-tutorial/#comments</comments>
		<pubDate>Mon, 08 Feb 2010 08:12:22 +0000</pubDate>
		<dc:creator>Wenbert</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[canvas]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[html5]]></category>

		<guid isPermaLink="false">http://blog.ekini.net/?p=692</guid>
		<description><![CDATA[The Paint Application from Mugtug.com is very impressive. It uses HTML5. Very responsive. I found it in HN and the hackers seemed to be impressed as well. 
Around the web, people are already talking about HTML5 and Canvas as a replacement for Flash. Click here to read the Canvas Tutorial.
]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://mugtug.com/sketchpad/">Paint Application from Mugtug.com</a> is very impressive. It uses HTML5. Very responsive. I found it in <a href="http://news.ycombinator.com/item?id=1106720">HN</a> and the hackers seemed to be impressed as well. </p>
<p>Around the web, people are already talking about HTML5 and Canvas as a replacement for Flash. Click <a href="http://billmill.org/static/canvastutorial/index.html">here</a> to read the Canvas Tutorial.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ekini.net/2010/02/08/html5-canvas-tutorial/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>An example of an Object-relational Mapper in PHP</title>
		<link>http://blog.ekini.net/2010/02/05/an-example-object-relational-mapper-in-php/</link>
		<comments>http://blog.ekini.net/2010/02/05/an-example-object-relational-mapper-in-php/#comments</comments>
		<pubDate>Fri, 05 Feb 2010 15:00:04 +0000</pubDate>
		<dc:creator>Wenbert</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.ekini.net/?p=686</guid>
		<description><![CDATA[Dennis Hotson posted  in his blog a  brief and good example of an ORM for PHP.
What is an Object-relational Mapper?

Data management tasks in object-oriented (OO) programming are typically implemented by manipulating objects that are almost always non-scalar values. For example, consider an address book entry that represents a single person along with zero [...]]]></description>
			<content:encoded><![CDATA[<p>Dennis Hotson posted  in his blog a  <a href="http://dhotson.tumblr.com/post/372232082/a-little-object-relational-mapper-in-php">brief and good example</a> of an <a href="http://en.wikipedia.org/wiki/Object-relational_mapping">ORM</a> for PHP.</p>
<p><strong>What is an Object-relational Mapper?</strong></p>
<blockquote><p>
Data management tasks in object-oriented (OO) programming are typically implemented by manipulating objects that are almost always non-scalar values. For example, consider an address book entry that represents a single person along with zero or more phone numbers and zero or more addresses. This could be modeled in an object-oriented implementation by a &#8220;person object&#8221; with &#8220;slots&#8221; to hold the data that comprise the entry: the person&#8217;s name, a list of phone numbers, and a list of addresses. The list of phone numbers would itself contain &#8220;phone number objects&#8221; and so on. The address book entry is treated as a single value by the programming language (it can be referenced by a single variable, for instance). Various methods can be associated with the object, such as a method to return the preferred phone number, the home address, and so on.</p>
<p>However, many popular database products such as structured query language database management systems (SQL DBMS) can only store and manipulate scalar values such as integers and strings organized within normalized tables. The programmer must either convert the object values into groups of simpler values for storage in the database (and convert them back upon retrieval), or only use simple scalar values within the program. Object-relational mapping is used to implement the first approach.</p>
<p>The heart of the problem is translating those objects to forms that can be stored in the database for easy retrieval, while preserving the properties of the objects and their relationships; these objects are then said to be persistent.</p>
<p><a href="http://en.wikipedia.org/wiki/Object-relational_mapping">-Wikipedia</a>
</p></blockquote>
<p>The full source code can be found in <a href="http://gist.github.com/295737">Github</a>.</p>
<p>I&#8217;m sure this will come in handy as a reference in the future. Thanks to <a href="http://dhotson.tumblr.com/">Dennis Hotson</a> for sharing.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ekini.net/2010/02/05/an-example-object-relational-mapper-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Quick Update</title>
		<link>http://blog.ekini.net/2010/01/29/a-quick-update/</link>
		<comments>http://blog.ekini.net/2010/01/29/a-quick-update/#comments</comments>
		<pubDate>Fri, 29 Jan 2010 14:05:44 +0000</pubDate>
		<dc:creator>Wenbert</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[news]]></category>

		<guid isPermaLink="false">http://blog.ekini.net/2010/01/29/a-quick-update/</guid>
		<description><![CDATA[Hello All. Sorry for the few updates. I have not been doing any Zend Framework / PHP related work for over a month now. I am in Aurland, Norway for a training. I will be staying here for about three months. I will be back home on April 2010.
Right now, I am thinking of starting [...]]]></description>
			<content:encoded><![CDATA[<p>Hello All. Sorry for the few updates. I have not been doing any Zend Framework / PHP related work for over a month now. I am in Aurland, Norway for a training. I will be staying here for about three months. I will be back home on April 2010.</p>
<p>Right now, I am thinking of starting a new pet project. I have the initial specifications in my head and I will put it into writing when I have time.</p>
<p>I will have more updates and Zend Framework / jQuery / PHP / MySQL / web development related soon.</p>
<p>Thanks!</p>
<p>-wenbert</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ekini.net/2010/01/29/a-quick-update/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Excel-like Javascript Grid Editors</title>
		<link>http://blog.ekini.net/2010/01/19/excel-like-javascript-grid-editors/</link>
		<comments>http://blog.ekini.net/2010/01/19/excel-like-javascript-grid-editors/#comments</comments>
		<pubDate>Tue, 19 Jan 2010 10:44:40 +0000</pubDate>
		<dc:creator>Wenbert</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.ekini.net/?p=683</guid>
		<description><![CDATA[Here is quick quote:
 A short list of my favorite JavaScript grid components.
How many times did you hear users asking you: “something simple, a grid like excel”?
When I was a VB programmer, oh yes, I have this dark spot on my career, and it is not the only one… this request threw me in panic. [...]]]></description>
			<content:encoded><![CDATA[<p>Here is quick quote:</p>
<blockquote><p> A short list of my favorite JavaScript grid components.<br />
How many times did you hear users asking you: “something simple, a grid like excel”?</p>
<p>When I was a VB programmer, oh yes, I have this dark spot on my career, and it is not the only one… this request threw me in panic. Usually what your “killer” is asking you is not what you, programmer, are thinking of (namely the power of cell functions, programmability, graph etc., that probably your “killer” does not even imagine): what they are thinking about is the editor flexibility, the ability to add columns, rows, move cells blocks, copy and paste from different sources.</p>
<p>After the ritual pointing-out that your application is NOT Excel, the VB solution was to adopt the standard flexGrid or the mythical TrueDbGrid that made happy both the killer-user and the victim-programmer.
</p></blockquote>
<p>The source here: <a href="http://roberto.open-lab.com/2010/01/18/javascript-grid-editor-i-want-to-be-excel/">roberto.open-lab.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ekini.net/2010/01/19/excel-like-javascript-grid-editors/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zend Framework: Accessing configuration data in application.ini</title>
		<link>http://blog.ekini.net/2009/12/29/zend-framework-accessing-configuration-data-in-application-ini/</link>
		<comments>http://blog.ekini.net/2009/12/29/zend-framework-accessing-configuration-data-in-application-ini/#comments</comments>
		<pubDate>Tue, 29 Dec 2009 05:13:31 +0000</pubDate>
		<dc:creator>Wenbert</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.ekini.net/?p=680</guid>
		<description><![CDATA[Lately, I haven&#8217;t been doing any Zend Framework related things. Although currently tied up with other stuff, I check the community from time to time. Today, I found this quick and useful tip from Akrabat.
Akra talks about how you can access your configuration that you have set in your application.ini file &#8211; your configuration file.
Since [...]]]></description>
			<content:encoded><![CDATA[<p>Lately, I haven&#8217;t been doing any Zend Framework related things. Although currently tied up with other stuff, I check the community from time to time. Today, I found this quick and useful tip from <a href="http://akrabat.com/">Akrabat</a>.</p>
<p>Akra talks about how you can access your configuration that you have set in your application.ini file &#8211; your configuration file.</p>
<p>Since it is a short post, I will copy-paste everything here.</p>
<p>Zend_Application will read the data in your application.ini and make it available from your bootstrap&#8217;s getOptions() method. It then sets the bootstrap as a parameter in the front controller. Note that the top level keys are all normalised to lowercase too.</p>
<p>You can then retrieve the options in a number of ways.</p>
<p>In the controller you can do this:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> someAction<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$bootstrap</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getInvokeArg</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'bootstrap'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
        <span style="color: #000088;">$options</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$bootstrap</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getOptions</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span></pre></div></div>

<p>Outside of the controller you can do this:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">    <span style="color: #000088;">$bootstrap</span> <span style="color: #339933;">=</span> Zend_Controller_Front<span style="color: #339933;">::</span><span style="color: #004000;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getParam</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'bootstrap'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$options</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$bootstrap</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getOptions</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>One downside is that $options is a nested array, and not a Zend_Config object. If you prefer to work with a Zend_Config object you need to create it yourself as Zend_Application discards the one it creates. The easiest way to do this is to create a new method in your bootstrap to create the Zend_Config object and store to the registry.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">    protected <span style="color: #000000; font-weight: bold;">function</span> _initConfig<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$config</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Config<span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getOptions</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        Zend_Registry<span style="color: #339933;">::</span><span style="color: #004000;">set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'config'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$config</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$config</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span></pre></div></div>

<p>You can then get at your config data wherever you need it. Try not to depend too much on Zend_Registry keys though, as it can make testing harder.</p>
<p>Of course, the source is <a href="http://akrabat.com/zend-framework/accessing-your-configuration-data-in-application-ini/">found here</a> with all the comments from Akrabat&#8217;s readers.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ekini.net/2009/12/29/zend-framework-accessing-configuration-data-in-application-ini/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>My free Wordpress Theme: Warmth</title>
		<link>http://blog.ekini.net/2009/12/16/my-free-wordpress-theme-warmth/</link>
		<comments>http://blog.ekini.net/2009/12/16/my-free-wordpress-theme-warmth/#comments</comments>
		<pubDate>Wed, 16 Dec 2009 08:18:11 +0000</pubDate>
		<dc:creator>Wenbert</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[freebies]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[wordpress theme]]></category>

		<guid isPermaLink="false">http://blog.ekini.net/?p=671</guid>
		<description><![CDATA[I got bored and spent a few days creating a theme in Wordpress. This is a quick release of the theme and I tested this in Firefox and Chrome. 
You can download it here.
Nothing special except that I spent about 4 hours creating the header image for it. LOL :P
Also, I have not validated the [...]]]></description>
			<content:encoded><![CDATA[<p>I got bored and spent a few days creating a theme in Wordpress. This is a quick release of the theme and I tested this in Firefox and Chrome. <img src="http://blog.ekini.net/wp-content/uploads/2009/12/screenshot.png" alt="screenshot" title="screenshot" width="300" height="225" class="alignleft size-full wp-image-672" align="left"/></p>
<p><strong>You can download it <a href="http://www.ekini.net/warmth.zip">here</a>.</strong></p>
<p>Nothing special except that I spent about 4 hours creating the header image for it. LOL :P</p>
<p>Also, I have not validated the HTML and CSS for this theme. I got tired and I need to do something else &#8211; um like play CounterStrike: Source (?). But seriously, I am starting to get busy and thought that I should finish and release this now.</p>
<p>And oh, by the way, Eddie Vedder is in the theme. Just wanted to share. Thanks!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ekini.net/2009/12/16/my-free-wordpress-theme-warmth/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>I&#8217;m giving away 20 Google Wave invites!</title>
		<link>http://blog.ekini.net/2009/12/01/im-giving-away-20-google-wave-invites/</link>
		<comments>http://blog.ekini.net/2009/12/01/im-giving-away-20-google-wave-invites/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 05:54:27 +0000</pubDate>
		<dc:creator>Wenbert</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[gmail]]></category>
		<category><![CDATA[google wave]]></category>

		<guid isPermaLink="false">http://blog.ekini.net/?p=667</guid>
		<description><![CDATA[I have 20 available Google Invites. Leave your email below. Format it to something like youremail[AT]gmail.com or something to avoid getting spammed. Just leave your email in the Email textbox when commenting :P
First 20 legit emails will get the invites.
UPDATE:
I still have around 10 or so invites left.
]]></description>
			<content:encoded><![CDATA[<p>I have 20 available Google Invites. Leave your email below.<del datetime="2009-12-01T05:55:25+00:00"> Format it to something like <strong>youremail[AT]gmail.com</strong> or something to avoid getting spammed.</del> Just leave your email in the Email textbox when commenting :P</p>
<p>First 20 legit emails will get the invites.</p>
<p><strong>UPDATE:</strong><br />
I still have around 10 or so invites left.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ekini.net/2009/12/01/im-giving-away-20-google-wave-invites/feed/</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
		<item>
		<title>CSS Buttons: Simply Buttons V2</title>
		<link>http://blog.ekini.net/2009/11/24/css-buttons-simply-buttons-v2/</link>
		<comments>http://blog.ekini.net/2009/11/24/css-buttons-simply-buttons-v2/#comments</comments>
		<pubDate>Tue, 24 Nov 2009 06:52:01 +0000</pubDate>
		<dc:creator>Wenbert</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[buttons]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[html]]></category>

		<guid isPermaLink="false">http://blog.ekini.net/2009/11/24/css-buttons-simply-buttons-v2/</guid>
		<description><![CDATA[Thanks to Jack for posintg this.

And from the official Simply-Buttons V2 site:
Benefits

Buttons size to fit text.
There are 3 states: Inactive, Active, and Hover.
They look and behave the same way in every browser and operating system.
The do not need the javascript to work, they work with just the css
Way better looking buttons than what anyone else [...]]]></description>
			<content:encoded><![CDATA[<p>Thanks to Jack for posintg <a href="http://itlivewire.com/devblog/?p=185">this</a>.</p>
<p><img src="http://blog.ekini.net/wp-content/uploads/2009/11/buttons-2.jpg" alt="buttons-2" title="buttons-2" width="499" height="163" class="aligncenter size-full wp-image-664" /></p>
<p>And from the official Simply-Buttons V2 site:</p>
<p><b>Benefits</b></p>
<ul>
<li>Buttons size to fit text.</li>
<li>There are 3 states: Inactive, Active, and Hover.
<li>They look and behave the same way in every browser and operating system.</li>
<li>The do not need the javascript to work, they work with just the css</li>
<li>Way better looking buttons than what anyone else can do with XHTML/CSS, isn’t that reason enough?!</li>
</ul>
<p><b>How it works</b><br />
The markup is pretty simple, as you can see below. The thing to notice here is that both the button and link tags each have a nested-nested span tag.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;button&gt;
  &lt;span&gt;&lt;span&gt;Button&lt;/span&gt;&lt;/span&gt;
&lt;/button&gt; 
&lt;a class=&quot;button&quot;&gt;
  &lt;span&gt;&lt;span&gt;Button&lt;/span&gt;&lt;/span&gt;
&lt;/a&gt;</pre></div></div>

<p>Grab it <a href="http://www.p51labs.com/simply-buttons-v2/">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ekini.net/2009/11/24/css-buttons-simply-buttons-v2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Ekini Edit: A gEdit Scheme that is dark and suitable for low-light conditions</title>
		<link>http://blog.ekini.net/2009/11/19/ekini-edit-a-gedit-scheme-that-is-dark-and-suitable-for-low-light-conditions/</link>
		<comments>http://blog.ekini.net/2009/11/19/ekini-edit-a-gedit-scheme-that-is-dark-and-suitable-for-low-light-conditions/#comments</comments>
		<pubDate>Thu, 19 Nov 2009 07:49:00 +0000</pubDate>
		<dc:creator>Wenbert</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[color scheme]]></category>
		<category><![CDATA[ekini edit]]></category>
		<category><![CDATA[gedit]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://blog.ekini.net/?p=643</guid>
		<description><![CDATA[A dark scheme with reduced glare and improved readability. The scheme is called Ekini Edit, it is based on the Zendburn and Thankful Eyes. 
UPDATE: Wow, this post has recently been getting a lot of attention from StumbleUpon. Please keep the fire burning by Stumbling/sharing this post. Thanks everyone!



Click here to download.
How to install:

Edit
Preferences
Fonts &#38; [...]]]></description>
			<content:encoded><![CDATA[<p>A dark scheme with reduced glare and improved readability. The scheme is called Ekini Edit, it is based on the Zendburn and Thankful Eyes. </p>
<p><strong>UPDATE:</strong> <em>Wow, this post has recently been getting a lot of attention from StumbleUpon. Please keep the fire burning by Stumbling/sharing this post. <strong>Thanks everyone!</strong></em></p>
<p><a href="http://www.ekini.net/ekini_edit.xml"><br />
<img border="0" src="http://blog.ekini.net/wp-content/uploads/2009/11/ekini_edit1.png" alt="ekini_edit" title="ekini_edit" width="531" height="584" class="aligncenter size-full wp-image-650" /><br />
</a></p>
<p><strong><a href="http://www.ekini.net/ekini_edit.xml">Click here to download.</a></strong></p>
<p><strong>How to install:</strong></p>
<ol>
<li>Edit</li>
<li>Preferences</li>
<li>Fonts &amp; Colors</li>
<li>Add ekini_edit.xml</li>
</ol>
<p><img src="http://blog.ekini.net/wp-content/uploads/2009/11/fonts_colors.png" alt="fonts_colors" title="fonts_colors" width="399" height="474" class="aligncenter size-full wp-image-655" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ekini.net/2009/11/19/ekini-edit-a-gedit-scheme-that-is-dark-and-suitable-for-low-light-conditions/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Meet my new text editor, Gedit (like Textmate for Linux)</title>
		<link>http://blog.ekini.net/2009/11/19/meet-my-new-text-editor-gedit-like-textmate-for-linux/</link>
		<comments>http://blog.ekini.net/2009/11/19/meet-my-new-text-editor-gedit-like-textmate-for-linux/#comments</comments>
		<pubDate>Thu, 19 Nov 2009 05:19:23 +0000</pubDate>
		<dc:creator>Wenbert</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[editor]]></category>
		<category><![CDATA[gedit]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[text editor]]></category>
		<category><![CDATA[textmate]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://blog.ekini.net/?p=633</guid>
		<description><![CDATA[I have new text editor for my Ubuntu box. Meet Gedit. For Ubuntu users, you can use your Synaptic Package Manager to install it.

Gedit itself at start is very basic and bare. So, I have come up with the best (*SEO-thingy* :P) and most useful plugins that I am using right now:

Advanced Bookmarks Useful for [...]]]></description>
			<content:encoded><![CDATA[<p>I have new text editor for my Ubuntu box. Meet <a href="http://projects.gnome.org/gedit/"><strong>Gedit</strong></a>. For Ubuntu users, you can use your <em>Synaptic Package Manager</em> to install it.<br />
<img src="http://blog.ekini.net/wp-content/uploads/2009/11/gedit_synaptic.png" /></p>
<p>Gedit itself at start is very basic and bare. So, I have come up with the best (*SEO-thingy* :P) and most useful plugins that I am using right now:</p>
<ol>
<li><a href="http://code.google.com/p/advanced-bookmarks-gedit-plugin/">Advanced Bookmarks</a> Useful for long code. Allows you to have a Bookmark Manager.</li>
<li><a href="http://live.gnome.org/GeditPlugins">Bracket Completion</a></li>
<li><a href="http://live.gnome.org/GeditPlugins">Code Comment</a></li>
<li><a href="http://live.gnome.org/GeditPlugins">Color Picker</a></li>
<li><a href="http://empty.23inch.de/pmwiki.php/Main/EditShortcuts">Edit Shortcuts</a></li>
<li><a href="http://live.gnome.org/GeditPlugins">Embedded Termimal</a></li>
<li><a href="http://live.gnome.org/Gedit/Plugins">File Browser Pane</a> <strong>Very sweet.</strong> You can create a &#8220;Bookmark&#8221; to your FTP server and browse your remote directories with gedit.</li>
<li><a href="http://code.google.com/p/gedit-ftp-browser/">FTP Browser</a></li>
<li><a href="http://live.gnome.org/Gedit/LineToolsPlugin">Line Tools</a> Allows you to duplicate lines, remove a line, etc.</li>
<li><a href="http://github.com/MichaelCereda/CMYKProjectManager/">CMYK Project Manager</a> Useful for local projects. But this one does not allow you to create a project using an FTP Bookmark. Textmate-like.</li>
</ol>
<p>To install the plugins, just extract the files in this directory:</p>
<pre>
/home/[username]/.gnome2/gedit/plugins
OR
~/.gnome2/gedit/plugins
</pre>
<p>Gedit also has very nice themes. Here is what my gedit looks like:<br />
<img src="http://blog.ekini.net/wp-content/uploads/2009/11/gedit.png" /></p>
<p>Now that looks very sweet for a free editor. </p>
<p>* To create a <b>&#8220;Bookmark&#8221;</b> go to <b>&#8220;Places > Connect to server&#8230;&#8221;</b>, then enter the host and location of your remote directories.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ekini.net/2009/11/19/meet-my-new-text-editor-gedit-like-textmate-for-linux/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Zend Framework: Creating your own RESTful Services</title>
		<link>http://blog.ekini.net/2009/11/11/zend-framework-creating-your-own-restful-services/</link>
		<comments>http://blog.ekini.net/2009/11/11/zend-framework-creating-your-own-restful-services/#comments</comments>
		<pubDate>Wed, 11 Nov 2009 06:17:56 +0000</pubDate>
		<dc:creator>Wenbert</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[REST]]></category>
		<category><![CDATA[RESTful]]></category>
		<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://blog.ekini.net/2009/11/11/zend-framework-creating-your-own-restful-services/</guid>
		<description><![CDATA[Matthew Weier O&#8217;Phinney has a very useful post for the latest release (1.9) of Zend Framework.
As a followup to my previous post, I now turn to RESTful web services. I originally encountered the term when attending php&#124;tropics in 2005, where George Schlossnaggle likened it to simple GET and POST requests. Since then, the architectural style [...]]]></description>
			<content:encoded><![CDATA[<p>Matthew Weier O&#8217;Phinney has a very useful post for the latest release (1.9) of Zend Framework.</p>
<blockquote><p>As a followup to my previous post, I now turn to RESTful web services. I originally encountered the term when attending php|tropics in 2005, where George Schlossnaggle likened it to simple GET and POST requests. Since then, the architectural style &#8212; and developer understanding of the architectural style &#8212; has improved a bit, and a more solid definition can be made.<br />
At its heart, REST simply dictates that a given resource have a unique address, and that you interact with that resource using HTTP verbs. The standard verbs utilized are:</p>
<p>GET: retrieve a list of resources, or, if an identifier is present, view a single resource<br />
POST: create a new resource with the data provided in the POST<br />
PUT: update an existing resource as specified by an identifier, using the PUT data<br />
DELETE: delete an existing resource as specified by an identifier</p>
<p>The standard URL structure used is as follows:</p>
<p>&#8220;/resource&#8221; &#8211; GET (list) and POST operations<br />
&#8220;/resource/{identifier}&#8221; &#8211; GET (view), PUT, and DELETE operations</p>
<p>What the REST paradigm provides you is a simple, standard way to structure your CRUD (Create-Read-Update-Delete) applications. Due to the large number of REST clients available, it also means that if you follow the rules, you get a ton of interoperability with those clients.</p>
<p>As of Zend Framework 1.9.0, it&#8217;s trivially easy to create RESTful routes for your MVC application, as well as to handle the various REST actions via action controllers.</p></blockquote>
<p>The full article is here: <a href="http://weierophinney.net/matthew/archives/228-Building-RESTful-Services-with-Zend-Framework.html">http://weierophinney.net/matthew/archives/228-Building-RESTful-Services-with-Zend-Framework.html</a>.</p>
<p>I am pretty sure that this post will come in handy for me.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ekini.net/2009/11/11/zend-framework-creating-your-own-restful-services/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Zend Framework 1.8 Web Application Development from Packt Publishing</title>
		<link>http://blog.ekini.net/2009/11/09/zend-framework-18-web-application-development-from-packt-publishing/</link>
		<comments>http://blog.ekini.net/2009/11/09/zend-framework-18-web-application-development-from-packt-publishing/#comments</comments>
		<pubDate>Mon, 09 Nov 2009 11:25:06 +0000</pubDate>
		<dc:creator>Wenbert</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[book]]></category>
		<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://blog.ekini.net/2009/11/09/zend-framework-18-web-application-development-from-packt-publishing/</guid>
		<description><![CDATA[A few months back, I participated in reviewing Zend Framework 1.8 Web Application Development written by Keith Pope.
The book is now published and released. You can get it here: http://www.packtpub.com/zend-framework-1-8-web-application-development
This book is for PHP web developers who want to get started with Zend Framework. If you are already using this framework, you will learn how [...]]]></description>
			<content:encoded><![CDATA[<p>A few months back, I participated in reviewing <strong>Zend Framework 1.8 Web Application Development</strong> written by Keith Pope.</p>
<p>The book is now published and released. You can get it here: http://www.packtpub.com/zend-framework-1-8-web-application-development</p>
<blockquote><p>This book is for PHP web developers who want to get started with Zend Framework. If you are already using this framework, you will learn how to use it in the best way and produce better applications.</p>
<p>Basic knowledge of Object Oriented design will be helpful.</p></blockquote>
<p>I haven&#8217;t got the chance to read the printed version but hopefully I will be able to within the coming weeks.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ekini.net/2009/11/09/zend-framework-18-web-application-development-from-packt-publishing/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Zend Framework: Handling file uploads with Zend_File_Transfer</title>
		<link>http://blog.ekini.net/2009/11/09/zend-framework-handling-file-uploads-with-zend_file_transfer/</link>
		<comments>http://blog.ekini.net/2009/11/09/zend-framework-handling-file-uploads-with-zend_file_transfer/#comments</comments>
		<pubDate>Mon, 09 Nov 2009 06:47:29 +0000</pubDate>
		<dc:creator>Wenbert</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[Zend_File_Transfer]]></category>

		<guid isPermaLink="false">http://blog.ekini.net/2009/11/09/zend-framework-handling-file-uploads-with-zend_file_transfer/</guid>
		<description><![CDATA[Here is a tutorial on how to handle file uploads with Zend_File_Transfer.
Like so many of the other powerful components made available through the Zend Framework, the Zend_File_Transfer component is intended to make your life much easier when it comes to the task of uploading files from a user&#8217;s computer to a Web server. In actuality, [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a <a href="http://www.developer.com/open/article.php/10930_3844031_1/Managing-File-Uploads-with-the-Zend-Framework.htm">tutorial</a> on how to handle file uploads with Zend_File_Transfer.</p>
<blockquote><p>Like so many of the other powerful components made available through the Zend Framework, the Zend_File_Transfer component is intended to make your life much easier when it comes to the task of uploading files from a user&#8217;s computer to a Web server. In actuality, this component is much more flexible than merely handling uploads; it can also be used to transfer files using protocols such as FTP and WebDAV, however for the purposes of this tutorial we&#8217;ll stick to its initially stated purpose. Let&#8217;s begin by creating the simplest process possible in the upload action which is nonetheless capable of accepting and processing an uploaded file</p></blockquote>
<p>The post is by Jason Gilmore from <a href="http://EasyPHPWebsites.com">EasyPHPWebsites.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ekini.net/2009/11/09/zend-framework-handling-file-uploads-with-zend_file_transfer/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Newline character &#8220;\n&#8221; problems in a Javascript string + PHP</title>
		<link>http://blog.ekini.net/2009/10/27/newline-character-n-problems-in-php-and-javascript/</link>
		<comments>http://blog.ekini.net/2009/10/27/newline-character-n-problems-in-php-and-javascript/#comments</comments>
		<pubDate>Tue, 27 Oct 2009 10:43:44 +0000</pubDate>
		<dc:creator>Wenbert</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[newline]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://blog.ekini.net/2009/10/27/newline-character-n-problems-in-php-and-javascript/</guid>
		<description><![CDATA[I have just spent an hour an a half trying to figure out why the newline character &#8220;\n&#8221; caused an error in my Javascript. I am posting this because I have been unsuccessful in finding a solution to this problem.
I am basically trying to display a newline character inside a textbox.

&#60;?php
$var = &#34;This is the [...]]]></description>
			<content:encoded><![CDATA[<p>I have just spent an hour an a half trying to figure out why the newline character &#8220;\n&#8221; caused an error in my Javascript. I am posting this because I have been unsuccessful in finding a solution to this problem.</p>
<p>I am basically trying to display a newline character inside a textbox.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$var</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;This is the first line. <span style="color: #000099; font-weight: bold;">\n</span> This is the second line.&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
&lt;textarea id=&quot;mytext&quot;&gt;&lt;/textarea&gt;
&nbsp;
&lt;script type=&quot;text/javascript&quot; language=&quot;javascript&quot;&gt;
    $(document).ready( function () {
        $('#mytime').val('<span style="color: #000000; font-weight: bold;">&lt;?=</span><span style="color: #000088;">$var</span><span style="color: #000000; font-weight: bold;">?&gt;</span>')
    });
&lt;/script&gt;</pre></div></div>

<p>The error I get above is:</p>
<pre>
unterminated string literal
</pre>
<p>When I view the source code, I have this:</p>
<pre>
$('#mytime').val('This is the first line.
This is the second line.');
</pre>
<p><strong>Using str_replace() to remove the &#8220;\n&#8221;</strong><br />
Apparently, this does not work.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$temp</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$var</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//does not work</span></pre></div></div>

<p>Has anyone experienced this issue? </p>
<p>Thanks,<br />
Wenbert</p>
<p><strong>UPDATE:</strong><br />
I found this in <a href="http://stackoverflow.com/questions/168214/pass-a-php-string-to-a-javascript-variable-including-escaping-newlines">Stackoverflow</a>. </p>
<p>The solution, use <strong>json_encode()</strong>.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$var</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;This is the first line. <span style="color: #000099; font-weight: bold;">\n</span> This is the second line.&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
&lt;textarea id=&quot;mytext&quot;&gt;&lt;/textarea&gt;
&nbsp;
&lt;script type=&quot;text/javascript&quot; language=&quot;javascript&quot;&gt;
    $(document).ready( function () {
        $('#mytime').val('<span style="color: #000000; font-weight: bold;">&lt;?=</span><span style="color: #990000;">json_encode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$var</span><span style="color: #009900;">&#41;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>')
    });
&lt;/script&gt;</pre></div></div>

<p>There. Who would have thought of that?</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ekini.net/2009/10/27/newline-character-n-problems-in-php-and-javascript/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
