<?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>Winn &#187; PHP</title>
	<atom:link href="http://winn.ws/archives/tag/php/feed" rel="self" type="application/rss+xml" />
	<link>http://winn.ws</link>
	<description>Standards-based design &#38; development</description>
	<lastBuildDate>Wed, 01 Feb 2012 05:30:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Models in Skoot</title>
		<link>http://winn.ws/archives/945</link>
		<comments>http://winn.ws/archives/945#comments</comments>
		<pubDate>Sat, 16 Jul 2011 17:33:58 +0000</pubDate>
		<dc:creator>Greg Winn</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Platforms]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Skoot]]></category>

		<guid isPermaLink="false">http://winn.ws/?p=945</guid>
		<description><![CDATA[Models are the &#8220;M&#8221; in &#8220;MVC&#8221;, and play a key roll in keeping your separation.What I will be covering here can be taken to most PHP frameworks with a little tweak. Below I will cover how to use the Models in the Skoot PHP framework. First a little about Skoot: This small but powerful PHP [...]]]></description>
			<content:encoded><![CDATA[<p>Models are the &#8220;M&#8221; in &#8220;MVC&#8221;, and play a key roll in keeping your separation.What I will be covering here can be taken to most PHP frameworks with a little tweak.</p>
<p>Below I will cover how to use the Models in the Skoot PHP framework. First a little about Skoot:</p>
<p>This small but powerful PHP “micro” framework is a result from another  project. I started using a “micro” framework called NiceDog, NiceDog is a  very cool little one file framework that is super simple to use and get  started with. It lacks the basic needs such as a database layer and  theme helpers but it’s great to use for projects that don’t need a full  framework with all the bells and whistles.</p>
<p>The name Skoot comes from my dog “Skooter” he’s a little black MinPin.  The Skoot framework adds the basic database layer and layout functions  into NiceDog making it more powerful and giving you a big jump start on  any small project.</p>
<h3>Let&#8217;s Start</h3>
<p>Looking into the basic setup the &#8220;welcome&#8221; controller we will see no reference to the model in any way. We can simple do that by building a construct:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> Welcome<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;">UsersModel</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> User<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>Above we are making a call to the Users model from the welcome controller. You can now access any of your model actions from &#8220;$this-&gt;UserModel-&gt;ACTION&#8221;. Let look at how to make sure the model is usable and of correct setup.</p>
<h3>The Model</h3>
<p>Below is how to construct a model in Skoot PHP framework:</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: #000000; font-weight: bold;">class</span> Users <span style="color: #000000; font-weight: bold;">extends</span> M <span style="color: #009900;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">function</span> test<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
      <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Test&quot;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>All models extend the class &#8220;M&#8221;, just like controllers extend &#8220;C&#8221;.</p>
<p>Now lets make a call to the model from the controller:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> index<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;">UsersModel</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">test</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>The above output would be &#8220;Test&#8221;.</p>
<h3>Don&#8217;t have Skoot?</h3>
<ul>
<li><a href="http://github.com/gregwinn/Skoot">Get Skoot!</a></li>
<li><a href="http://github.com/gregwinn/Skoot/wiki">Skoot Docs</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://winn.ws/archives/945/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Capistrano and PHP</title>
		<link>http://winn.ws/archives/924</link>
		<comments>http://winn.ws/archives/924#comments</comments>
		<pubDate>Wed, 01 Jun 2011 14:30:17 +0000</pubDate>
		<dc:creator>Greg Winn</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://winn.ws/?p=924</guid>
		<description><![CDATA[Capistrano loves PHP also! When I say Capistrano to most PHP developer they think Ruby on Rails right away. This is mostly the case because Capistrano got it’s fame from the Rails community. Capistrano has been good to thousands and thousands of Rails developers so why can it do the same for a PHP developer [...]]]></description>
			<content:encoded><![CDATA[<p><img title="PHP" alt="Capistrano" src="http://d45jz936mo8n8.cloudfront.net/wp-content/uploads/2011/01/phpicon.jpg" class="codeicon"></p>
<h3>Capistrano loves PHP also!</h3>
<p>When I say Capistrano to most PHP developer they think Ruby on Rails right away. This is mostly the case because Capistrano got it’s fame from the Rails community. Capistrano has been good to thousands and thousands of Rails developers so why can it do the same for a PHP developer here or there? Well i have great news for you, it can.  In fact you can start using it on your current project today!</p>
<p><span id="more-924"></span></p>
<h3>Whats needed to start using Capistrano?</h3>
<p>Well Capistrano runs as a gem on Ruby, so you will need to install Ruby on your system.</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">sudo aptitude install ruby build-essential libopenssl-ruby ruby1.8-dev</pre></div></div>

<p>After you have Ruby installed you can now run a simple command to install one of the greatest gem’s of all time.</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">sudo gem install capistrano</pre></div></div>

<p>Now lets setup Capistrano in your project new or existing. To do so lets just run a simple command in the root directory of your project.</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">capify .</pre></div></div>

<p style="text-align:center;"><script type="text/javascript"><!--
google_ad_client = "pub-9763253940568418";
/* 468x15, created 5/28/10 */
google_ad_slot = "4528267187";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p>After that lets edit your configuration file; below are the important items you should add or edit.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">ssh_options<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:keys</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#006600; font-weight:bold;">%</span>w<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">/</span>Users<span style="color:#006600; font-weight:bold;">/</span>username<span style="color:#006600; font-weight:bold;">/</span>.<span style="color:#9900CC;">ssh</span><span style="color:#006600; font-weight:bold;">/</span>id_rsa<span style="color:#006600; font-weight:bold;">&#41;</span>
default_run_options<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:pty</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#0000FF; font-weight:bold;">true</span>
set <span style="color:#ff3333; font-weight:bold;">:use_sudo</span>, <span style="color:#0000FF; font-weight:bold;">true</span>
set <span style="color:#ff3333; font-weight:bold;">:application</span>, <span style="color:#996600;">&quot;App Name&quot;</span>
set <span style="color:#ff3333; font-weight:bold;">:repository</span>,  <span style="color:#996600;">&quot;git@gitpath.git&quot;</span>
set <span style="color:#ff3333; font-weight:bold;">:branch</span>, <span style="color:#996600;">&quot;master&quot;</span>
&nbsp;
set <span style="color:#ff3333; font-weight:bold;">:scm</span>, <span style="color:#ff3333; font-weight:bold;">:git</span>
<span style="color:#008000; font-style:italic;"># Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`</span>
&nbsp;
role <span style="color:#ff3333; font-weight:bold;">:web</span>, <span style="color:#996600;">&quot;url.com&quot;</span>                          <span style="color:#008000; font-style:italic;"># Your HTTP server, Apache/etc</span>
role <span style="color:#ff3333; font-weight:bold;">:app</span>, <span style="color:#996600;">&quot;url.com&quot;</span>                          <span style="color:#008000; font-style:italic;"># This may be the same as your `Web` server</span>
&nbsp;
set <span style="color:#ff3333; font-weight:bold;">:deploy_to</span>, <span style="color:#996600;">&quot;/var/www/app&quot;</span>
&nbsp;
namespace <span style="color:#ff3333; font-weight:bold;">:apache</span> <span style="color:#9966CC; font-weight:bold;">do</span>
  <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:stop</span>, <span style="color:#ff3333; font-weight:bold;">:start</span>, <span style="color:#ff3333; font-weight:bold;">:restart</span>, <span style="color:#ff3333; font-weight:bold;">:reload</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>action<span style="color:#006600; font-weight:bold;">|</span>
    desc <span style="color:#996600;">&quot;#{action.to_s.capitalize} Apache&quot;</span>
    task action, <span style="color:#ff3333; font-weight:bold;">:roles</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:web</span> <span style="color:#9966CC; font-weight:bold;">do</span>
      invoke_command <span style="color:#996600;">&quot;/etc/init.d/apache2 #{action.to_s}&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:via</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> run_method
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<h3>Now it’s time!</h3>
<p>Run the following command to setup the directory structure.</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">cap deploy:setup</pre></div></div>

<h3>Now lets deploy your code!</h3>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">cap deploy:cold</pre></div></div>

<h3>What about updates?</h3>
<p>Well cap will let you take care of this by simply running update like so:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">cap deploy:update</pre></div></div>

<p>Want more? Checkout this older post: <a href="http://wiki.ocssolutions.com/Step-by-step_setup_using_Capistrano_2.0_and_Mongrel">http://wiki.ocssolutions.com/Step-by-step_setup_using_Capistrano_2.0_and_Mongrel</a></p>
]]></content:encoded>
			<wfw:commentRss>http://winn.ws/archives/924/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Codeigniter Views</title>
		<link>http://winn.ws/archives/919</link>
		<comments>http://winn.ws/archives/919#comments</comments>
		<pubDate>Wed, 04 May 2011 02:50:05 +0000</pubDate>
		<dc:creator>Greg Winn</dc:creator>
				<category><![CDATA[Codeigniter]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[CodeIgniter]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://winn.ws/?p=919</guid>
		<description><![CDATA[Multiple views! Did you know you can load multiple views in a Codeigniter controller method? I have always believed it was one view to one action, but that is not the case! CodeIgniter will intelligently handle multiple calls to $this->load->view from within a controller. If more than one call happens they will be appended together. [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://d45jz936mo8n8.cloudfront.net/wp-content/uploads/2011/01/phpicon.jpg" class="codeicon" alt="php"></p>
<h3>Multiple views!</h3>
<p>Did you know you can load multiple views in a Codeigniter controller method? I have always believed it was one view to one action, but that is not the case! CodeIgniter will intelligently handle multiple calls to $this->load->view from within a controller. If more than one call happens they will be appended together. For example, you may wish to have a header view, a menu view, a content view, and a footer view. </p>
<p><span id="more-919"></span></p>
<h4>Example:</h4>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> Page <span style="color: #000000; font-weight: bold;">extends</span> CI_Controller <span style="color: #009900;">&#123;</span>
&nbsp;
   <span style="color: #000000; font-weight: bold;">function</span> anypage<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
   <span style="color: #009900;">&#123;</span>
      <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'page_title'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Title'</span><span style="color: #339933;">;</span>
&nbsp;
      <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">view</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'header'</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;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">view</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'nav'</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;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">view</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'content'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$data</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;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">view</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'footer'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>To make this easier you can store views within sub folders.</p>
<h3>Storing Views within Sub-folders</h3>
<p>Your view files can also be stored within sub-folders if you prefer that type of organization. When doing so you will need to include the folder name loading the view.</p>
<h4>Example:</h4>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">view</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'folder_name/view_name'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Thanks for reading, hope this helped!</p>
]]></content:encoded>
			<wfw:commentRss>http://winn.ws/archives/919/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Skoot PHP Framework</title>
		<link>http://winn.ws/archives/905</link>
		<comments>http://winn.ws/archives/905#comments</comments>
		<pubDate>Sat, 05 Mar 2011 05:26:19 +0000</pubDate>
		<dc:creator>Greg Winn</dc:creator>
				<category><![CDATA[Codeigniter]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://winn.ws/?p=905</guid>
		<description><![CDATA[Skoot a micro framework This small but powerful PHP “micro” framework is a result from another project. I started using a “micro” framework called NiceDog. NiceDog is a very cool little one file framework that is super simple to use and get started with. It lacks the basic needs such as a database layer and [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://d45jz936mo8n8.cloudfront.net/wp-content/uploads/2011/01/phpicon.jpg" class="codeicon" alt="php"></p>
<h3>Skoot a micro framework</h3>
<p>This small but powerful PHP “micro” framework is a result from another project. I started using a “micro” framework called NiceDog. NiceDog is a very cool little one file framework that is super simple to use and get started with. It lacks the basic needs such as a database layer and theme helpers but it’s great to use for projects that don’t need a full framework with all the bells and whistles.</p>
<p><span id="more-905"></span><br />
<a class="colorbox" href="http://d45jz936mo8n8.cloudfront.net/wp-content/uploads/2010/06/skooter_large.jpg"><img src="http://d45jz936mo8n8.cloudfront.net/wp-content/uploads/2010/06/skooter_75.jpg" class="codeicon" alt="Skoot" /></a></p>
<p>The name Skoot comes from my dog “Skooter” he’s a little black MinPin. The Skoot framework adds the basic database layer and layout functions into NiceDog making it more powerful and giving you a big jump start on any small project.</p>
<h3 class="clear">Getting started</h3>
<p>After you take a look at the demo code provided in the checkout over at Github you will quickly see that is very easy to use. Creating new methods is as simple as adding a new function like so:</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> index<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;">layout_tamplate</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'views/layouts/welcome.php'</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">render</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'views/welcome/index.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<h4>Database layer</h4>
<p>The database layer is much like codeigniter&#8217;s. So if your a CI fan like i am then you&#8217;ll quickly understand. Below are some basic methods:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// A basic select</span>
<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">select</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'*'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">from</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'users'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getQuery</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;">// A more complex query:</span>
<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">select</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'*'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">from</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'users'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">where</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'status'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><a href="https://github.com/gregwinn/Skoot/wiki/Method-chaining">View more examples here.</a></p>
<p><a href="https://github.com/gregwinn/Skoot">Download the framework and start building!</a></p>
]]></content:encoded>
			<wfw:commentRss>http://winn.ws/archives/905/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Caching Driver CI 2.0</title>
		<link>http://winn.ws/archives/856</link>
		<comments>http://winn.ws/archives/856#comments</comments>
		<pubDate>Fri, 28 Jan 2011 21:08:11 +0000</pubDate>
		<dc:creator>Greg Winn</dc:creator>
				<category><![CDATA[Codeigniter]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[CodeIgniter]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://winn.ws/?p=856</guid>
		<description><![CDATA[With the latest release of Codeigniter, they added whats called &#8220;Caching Driver&#8221; allowing you to now use Memcache without going to a separate library as detailed in an older post: Memcache with Codeigniter. They now also support File based caching, Alternative PHP Cache (APC) Caching and Dummy Cache. CodeIgniter features wrappers around some of the [...]]]></description>
			<content:encoded><![CDATA[<p><img alt="php" class="codeicon" src="http://d45jz936mo8n8.cloudfront.net/wp-content/uploads/2011/01/phpicon.jpg"></p>
<p>With the latest release of Codeigniter, they added whats called &#8220;Caching Driver&#8221; allowing you to now use Memcache without going to a separate library as detailed in an older post: <a href="http://winn.ws/archives/273">Memcache with Codeigniter</a>. They now also support File based caching, Alternative PHP Cache (APC) Caching and Dummy Cache.</p>
<p>CodeIgniter features wrappers around some of the most popular forms of fast and dynamic caching. All but file-based caching require specific server requirements, and a Fatal Exception will be thrown if server requirements are not met.</p>
<p><span id="more-856"></span></p>
<h4>Functions</h4>
<p><strong>get(id['string'])</strong></p>
<p>This function will attempt to fetch an item from the cache store. If the item does not exist, the function will return FALSE.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$foo</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">cache</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'my_cached_item'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><strong>save(id['string'], data['mixed'], ttl['int'])</strong></p>
<p>This function will save an item to the cache store. If saving fails, the function will return FALSE.</p>
<p>The optional third parameter (Time To Live) defaults to 60 seconds.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">cache</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">save</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'cache_item_id'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'data_to_cache'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><strong>delete(id['string'])</strong></p>
<p>This function will delete a specific item from the cache store. If item deletion fails, the function will return FALSE.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">cache</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">delete</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'cache_item_id'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><strong>cache_info()</strong></p>
<p>This function will return information on the entire cache. More for really debugging the application.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">var_dump</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">cache</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">cache_info</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h4>Drivers</h4>
<p>To get started load the cache driver into your project.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">driver</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'cache'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h5>Alternative PHP Cache (APC) Caching</h5>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">cache</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">apc</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">save</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'foo'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'bar'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h5>Memcached Caching</h5>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">cache</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">memcached</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">save</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'foo'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'bar'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h5>Memcached Caching</h5>
<p>Multiple Memcached servers can be specified in the memcached.php configuration file, located in the application/config/ directory.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">cache</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">memcached</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">save</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'foo'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'bar'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://winn.ws/archives/856/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Quick and Easy Way To Do Autocomplete</title>
		<link>http://winn.ws/archives/824</link>
		<comments>http://winn.ws/archives/824#comments</comments>
		<pubDate>Fri, 21 Jan 2011 21:15:41 +0000</pubDate>
		<dc:creator>Greg Winn</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[CodeIgniter]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://winn.ws/?p=824</guid>
		<description><![CDATA[Auto complete forms are now becoming essential to every day web development and knowing how to build such a tool will in some cases make you a hero! In the tutorial below i will be using PHP and jQuery. jQuery offers its own tool for this common problem in the jQuery UI library.]]></description>
			<content:encoded><![CDATA[<p><img src="http://d45jz936mo8n8.cloudfront.net/wp-content/uploads/2011/01/phpicon.jpg" class="codeicon" alt="php" /></p>
<p>This was written for a friend who was having issues with getting an auto complete form to work.</p>
<p>Auto complete forms are now becoming essential to every day web development and knowing how to build such a tool will in some cases make you a hero! In the tutorial below i will be using PHP and jQuery. jQuery offers its own tool for this common problem in the jQuery UI library.</p>
<p><span id="more-824"></span></p>
<blockquote>
<p>Autocomplete, when added to an input field, enables users to quickly find and select from a pre-populated list of values as they type, leveraging searching and filtering.</p>
<p>By giving an Autocomplete field focus or entering something into it, the plugin starts searching for entries that match and displays a list of values to choose from. By entering more characters, the user can filter down the list to better matches. This can be used to enter previous selected values, for example you could use Autocomplete for entering tags, to complete an address, you could enter a city name and get the zip code, or maybe enter email addresses from an address book. You can pull data in from a local and/or a remote source: Local is good for small data sets (like an address book with 50 entries), remote is necessary for big data sets, like a database with hundreds or millions of entries to select from.</p>
</blockquote>
<p>Lets get right into it. Lets say you need to pull a list of usernames from the database. So when the user types, it will start completing the username for them.
</p>
<h3>The HEAD of the document</h3>
<p>I will be including jQuery and jQuery UI into the page.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;script type=&quot;text/javascript&quot; src=&quot;http://code.jquery.com/jquery-1.4.4.min.js&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.6/jquery-ui.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&nbsp;
&lt;!-- You may also include the jQuery css document --&gt;</pre></td></tr></table></div>

<h3>The HTML:</h3>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;input id=&quot;get_usernames&quot; name=&quot;username&quot; type=&quot;text&quot; /&gt;</pre></div></div>

<p></small>As you see this is a super basic just one input needed.</small></p>
<h3>The Javascript:</h3>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="js" style="font-family:monospace;">$(&quot;#get_usernames&quot;).autocomplete({
	source: &quot;/search/get_username&quot;,
	minLength: 1
});</pre></td></tr></table></div>

<p>The above code is doing a few things first it’s looking to the id get_usernames (#get_usernames).  Now that we have found the element we want let’s add jQuery’s autocomplete to it. The autocomplete needs some basic stuff, first off lets tell it where to get the data (source: “/search/get_username”). Next lets tell it when to start looking, this should be an integer. In the sample i am telling autocomplete to look to the database after the user types in only 1 character. You can set this to what you need. (minLength: 1)</p>
<h3>The PHP (Using Codeigniter)</h3>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> get_username<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$usernames</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'term'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$usernames</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">select</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'username'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">from</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'users'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">where_like</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'username'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'term'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #990000;">json_encode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$usernames</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Need to return key and value?</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> get_username<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$usernames</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
                <span style="color: #000088;">$UList</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'term'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$usernames</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">select</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'username'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">from</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'users'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">where_like</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'username'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'term'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$usernames</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">result</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$user</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$UList</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$user</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">id</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$user</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">username</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #990000;">json_encode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$UList</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>You will see that we are looking for a request named “term” this is default. After getting the value i am selecting usernames like the one entered into the text field. After grabbing the data i am returning it in a json format by using (json_encode). This will then send the data back to the UI showing a list of usernames like the one you typed in.</p>
<p>Hope that helped!</p>
]]></content:encoded>
			<wfw:commentRss>http://winn.ws/archives/824/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PHP/MySQL after 2010-005</title>
		<link>http://winn.ws/archives/492</link>
		<comments>http://winn.ws/archives/492#comments</comments>
		<pubDate>Sat, 28 Aug 2010 07:22:27 +0000</pubDate>
		<dc:creator>Greg Winn</dc:creator>
				<category><![CDATA[Command Line]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://winn.ws/?p=492</guid>
		<description><![CDATA[After applying Security Update 2010-05, some users have reported PHP and MySQL problems, including an inability to connect to MySQL databases. Apple reports that the following procedure resolves the database connection issue: In the Terminal type sudo nano /etc/php.ini (Terminal will ask you for your password) Change: mysql.default_socket = to: mysql.default_socket = /tmp/mysql.sock Press Ctrl-O, [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://d45jz936mo8n8.cloudfront.net/wp-content/uploads/2011/01/phpicon.jpg" class="codeicon" alt="php" /></p>
<p>After applying Security Update 2010-05, some users have reported PHP and MySQL problems, including an inability to connect to MySQL databases. Apple reports that the following procedure resolves the database connection issue:</p>
<ol>
<li>In the Terminal type sudo nano /etc/php.ini (Terminal will ask you for your password)</li>
<li>Change: mysql.default_socket = to: mysql.default_socket = /tmp/mysql.sock</li>
<li>Press Ctrl-O, then Enter to save</li>
<li>Type sudo apachectl graceful</li>
</ol>
<p>Note that you may need to duplicate the original install php.ini.default file, just simply copy the contents of the file and create a php.ini. (cp php.ini.default php.ini)</p>
]]></content:encoded>
			<wfw:commentRss>http://winn.ws/archives/492/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>phpArmory for WoW</title>
		<link>http://winn.ws/archives/484</link>
		<comments>http://winn.ws/archives/484#comments</comments>
		<pubDate>Mon, 23 Aug 2010 02:17:51 +0000</pubDate>
		<dc:creator>Greg Winn</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[World of Warcraft]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://winn.ws/?p=484</guid>
		<description><![CDATA[phpArmory is a PHP class library. It allows php software developers to easily access data from the World of Warcraft Armory website. This is useful because the Armory website contains up-to-date and official details on characters, guilds, and items in World of Warcraft.]]></description>
			<content:encoded><![CDATA[<p><img src="http://d45jz936mo8n8.cloudfront.net/wp-content/uploads/2011/01/phpicon.jpg" class="codeicon" alt="php" /></p>
<p>phpArmory is a PHP class library. It allows php software developers to easily access data from the World of Warcraft Armory website. This is useful because the Armory website contains up-to-date and official details on characters, guilds, and items in World of Warcraft.</p>
<p><span id="more-484"></span></p>
<p> I discovered this simple library about 4 days ago and have been reviewing it. I came to a conclusion to use it after about 3 hours of playing with it! I was able to pull back all the information i needed to complete my new application and add-on to Wordboxes. Below i will cover a few samples of what this class will do.</p>
<h3>Character</h3>
<p> The first thing i did was try to pul my character information back. This was simple and done quickly with just a few minor calls. Once i got the multi level array back (when i say multi level I am talking about 4 to 5 levels deep) i was able to sift through it by using print_r() and a pre tag.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// First include the phpArmory class</span>
<span style="color: #b1b100;">include</span> <span style="color: #0000ff;">'classes/phpArmory.class.php'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$a</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> phpArmory<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;">// Character lookup</span>
<span style="color: #000088;">$character</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$a</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">characterFetch</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Name'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Realm'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">print_r</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$character</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p> Now, I wanted to take this a bit farther and list my characters gear with the image and item level. Below is a foreach loop, looping through the ‘item’ array. You may also notice i am 4 levels deep in the array at this point, i figured that out by just looking at the above code output. As i am looping through the ‘item’ array i will also have to step one level deeper into the ‘attributes’ array so i can see the information on the gear. </p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$character</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'characterinfo'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'charactertab'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'items'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'item'</span><span style="color: #009900;">&#93;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$item</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;p&gt;&lt;img class=&quot;gearicon&quot; src=&quot;http://www.wowarmory.com/wow-icons/_images/64x64/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$item</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'attributes'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'icon'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'.jpg&quot; alt=&quot;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$item</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'attributes'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot; /&gt;'</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$item</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'attributes'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">' (ilvl '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$item</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'attributes'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'level'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">')&lt;/p&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<h3>The above will output:</h3>
<p style="text-align:center;"><a class="colorbox" href="http://d45jz936mo8n8.cloudfront.net/wp-content/uploads/2010/08/wowarmoryphp.jpg"><img src="http://d45jz936mo8n8.cloudfront.net/wp-content/uploads/2010/08/wowarmoryphp-182x300.jpg" alt="" title="wowarmoryphp" width="182" height="300" class="aligncenter size-medium wp-image-485" /></a></p>
<h3>Items</h3>
<p>Another great thing about this library is that you are able to pull back just single items based on ID. This is great because after pulling back character info you also get gear ID&#8217;s. Then you can use the gear ID&#8217;s to get more information on that single item. This also makes it handy for tool tips as you will see on may wow sites.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Item lookup</span>
<span style="color: #000088;">$item</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$a</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">itemFetch</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">41922</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">print_r</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$item</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The above will be a large multi level array with that item information.</p>
<h3>Other stuff</h3>
<p>There are other things you can use this library for such as Guild lookups and PVP team lookups.</p>
<p>Download the <a href='http://d45jz936mo8n8.cloudfront.net/wp-content/uploads/2010/08/phpArmory.class.php_.zip'>phpArmory.class.php</a> and start building a web based wow app! Full documentation and support at <a href="http://phparmory.sourceforge.net/">http://phparmory.sourceforge.net/</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://winn.ws/archives/484/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP 5.3.3 Backwards incompatible change</title>
		<link>http://winn.ws/archives/470</link>
		<comments>http://winn.ws/archives/470#comments</comments>
		<pubDate>Wed, 04 Aug 2010 16:00:36 +0000</pubDate>
		<dc:creator>Greg Winn</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://winn.ws/?p=470</guid>
		<description><![CDATA[Methods with the same name as the last element of a namespaced class name will no longer be treated as constructor. This change doesn&#8217;t affect non-namespaced classes. namespace Foo; class Bar &#123; public function Bar&#40;&#41; &#123; // treated as constructor in PHP 5.3.0-5.3.2 // treated as regular method in PHP 5.3.3 &#125; &#125; Update from [...]]]></description>
			<content:encoded><![CDATA[<p>Methods with the same name as the last element of a namespaced class name will no longer be treated as constructor. This change doesn&#8217;t affect non-namespaced classes.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">namespace</span> Foo<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">class</span> Bar <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> Bar<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;">// treated as constructor in PHP 5.3.0-5.3.2</span>
        <span style="color: #666666; font-style: italic;">// treated as regular method in PHP 5.3.3</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Update from <a href="http://php.net">PHP.net</a></p>
]]></content:encoded>
			<wfw:commentRss>http://winn.ws/archives/470/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>var_export in PHP 5</title>
		<link>http://winn.ws/archives/468</link>
		<comments>http://winn.ws/archives/468#comments</comments>
		<pubDate>Wed, 04 Aug 2010 05:05:33 +0000</pubDate>
		<dc:creator>Greg Winn</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://winn.ws/?p=468</guid>
		<description><![CDATA[So var_export(mixed $expression [, bool $return = false ] ) outputs or returns a parsable string representation of a variable.]]></description>
			<content:encoded><![CDATA[<p>So var_export(mixed $expression [, bool $return = false ] ) outputs or returns a parsable string representation of a variable, it gets structured information about the given variable. It is similar to var_dump() with one exception: the returned representation is valid PHP code.</p>
<p>It&#8217;s quite simple to use, below is an example of how to use it.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> A <span style="color: #009900;">&#123;</span> 
     <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000088;">$var</span><span style="color: #339933;">;</span> 
<span style="color: #009900;">&#125;</span>
<span style="color: #000088;">$a</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> A<span style="color: #339933;">;</span>
<span style="color: #000088;">$a</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">var</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">5</span><span style="color: #339933;">;</span>
<span style="color: #990000;">var_export</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$a</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>The output from the above code would be&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">A<span style="color: #339933;">::</span>__set_state<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
   <span style="color: #0000ff;">'var'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">5</span><span style="color: #339933;">,</span>
<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span></pre></div></div>

<p><strong>Note:</strong> var_export() does not handle circular references as it would be close to impossible to generate parsable PHP code for that. If you want to do something with the full representation of an array or object, use serialize(). </p>
]]></content:encoded>
			<wfw:commentRss>http://winn.ws/archives/468/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Database Caching 1/50 queries in 0.023 seconds using disk: basic
Object Caching 612/722 objects using disk: basic
Content Delivery Network via Amazon Web Services: CloudFront: d45jz936mo8n8.cloudfront.net

Served from: winn.ws @ 2012-02-05 05:33:33 -->
