<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet href="/templates/default/atom.css" type="text/css" ?>

<feed 
   xmlns="http://www.w3.org/2005/Atom"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/">
    <link href="http://www.digitalsandwich.com/feeds/atom10.xml" rel="self" title="Digital Sandwich" type="application/atom+xml" />
    <link href="http://www.ds-o.com/"                        rel="alternate"    title="Digital Sandwich" type="text/html" />
    <link href="http://www.ds-o.com/rss.php?version=2.0"     rel="alternate"    title="Digital Sandwich" type="application/rss+xml" />
    <title type="html">Digital Sandwich</title>
    <subtitle type="html">PHP, Music, and other stuff</subtitle>
    <icon>http://www.ds-o.com/templates/default/img/s9y_banner_small.png</icon>
    <id>http://www.ds-o.com/</id>
    <updated>2009-02-04T03:56:00Z</updated>
    <generator uri="http://www.s9y.org/" version="1.2">Serendipity 1.2 - http://www.s9y.org/</generator>
    <dc:language>en</dc:language>

    <entry>
        <link href="http://www.ds-o.com/archives/79-YAML-Now-Supported-by-PHPUnit-Database-Extension.html" rel="alternate" title="YAML Now Supported by PHPUnit Database Extension" />
        <author>
            <name>Mike Lively</name>
            <email>nospam@example.com</email>
        </author>
    
        <published>2009-02-01T18:22:13Z</published>
        <updated>2009-02-04T03:56:00Z</updated>
        <wfw:comment>http://www.ds-o.com/wfwcomment.php?cid=79</wfw:comment>
    
        <slash:comments>8</slash:comments>
        <wfw:commentRss>http://www.ds-o.com/rss.php?version=atom1.0&amp;type=comments&amp;cid=79</wfw:commentRss>
    
            <category scheme="http://www.ds-o.com/categories/9-PHP-Testing" label="PHP Testing" term="PHP Testing" />
    
        <id>http://www.ds-o.com/archives/79-guid.html</id>
        <title type="html">YAML Now Supported by PHPUnit Database Extension</title>
        <content type="xhtml" xml:base="http://www.ds-o.com/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                <p>I have now just committed <a href="http://www.ds-o.com/exit.php?url_id=246&amp;entry_id=79" title="http://yaml.org/"  onmouseover="window.status='http://yaml.org/';return true;" onmouseout="window.status='';return true;">YAML</a> data sets to the Database Extension for <a href="http://www.ds-o.com/exit.php?url_id=247&amp;entry_id=79" title="http://www.phpun.it"  onmouseover="window.status='http://www.phpun.it';return true;" onmouseout="window.status='';return true;">PHPUnit</a>. So now all those that love the simplicity and straightforwardness of YAML can use it with your data sets. I have also created a persistor for YAML datasets so you can easily convert existing data sets or database data into YAML representations.</p>

<p>This is really the first I have dealt with YAML and it is definitely a viable alternative for data sets. Here is what they will look like.</p>

<div style="text-align: left"><br />table1:<br />&#160; -<br />&#160; &#160; table1_id: 1<br />&#160; &#160; columnName1: &quot;tgfahgasdf&quot;<br />&#160; &#160; columnName2: 200<br />&#160; &#160; columnName3: 34.64<br />&#160; &#160; columnName4: yghkf;a&#160; hahfg8ja h;<br />table2:<br />&#160; -<br />&#160; &#160; table2_id: 1<br />&#160; &#160; column5: fhah<br />&#160; &#160; column6: 456<br />&#160; &#160; column7: 46.5<br />&#160; &#160; column8: &quot;fsdb, ghfdas&quot;<br />&#160; -<br />&#160; &#160; table2_id: 3<br />&#160; &#160; column5: ajsdlkfguitah<br />&#160; &#160; column6: 654<br />&#160; &#160; column7: blah<br />&#160; &#160; column8: |-<br />&#160; &#160; &#160; thesethasdl<br />&#160; &#160; &#160; asdflkjsadf asdfsadfhl &quot;adsf, halsdf&quot; sadfhlasdf<br /></div>

<p>The biggest issue I had was figuring out how YAML dealt with trailing line breaks. It appears that '|-' did the trick. It will strip the final line break. Another thing to take note is that indention is important. It doesn't HAVE to be spaces (it can be tabs) it just needs to be consistent. The last thing is that strings do not need to be quoted, but if they are you can use escape characters (like \n.)</p>

<p>This was committed to the trunk of PHPUnit and I anticipate Sebastian will be merging it back into 3.4 shortly.</p> 
            </div>
        </content>
        
    </entry>
    <entry>
        <link href="http://www.ds-o.com/archives/78-Improved-PHPUnit-Filters.html" rel="alternate" title="Improved PHPUnit Filters" />
        <author>
            <name>Mike Lively</name>
            <email>nospam@example.com</email>
        </author>
    
        <published>2009-02-01T04:54:28Z</published>
        <updated>2009-02-01T04:58:04Z</updated>
        <wfw:comment>http://www.ds-o.com/wfwcomment.php?cid=78</wfw:comment>
    
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://www.ds-o.com/rss.php?version=atom1.0&amp;type=comments&amp;cid=78</wfw:commentRss>
    
            <category scheme="http://www.ds-o.com/categories/9-PHP-Testing" label="PHP Testing" term="PHP Testing" />
    
        <id>http://www.ds-o.com/archives/78-guid.html</id>
        <title type="html">Improved PHPUnit Filters</title>
        <content type="xhtml" xml:base="http://www.ds-o.com/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                <p>I have finally gotten some time to do some long awaited work on PHPUnit. The first on my agenda was a small improvement to filtering. This was related to <a href="http://www.ds-o.com/exit.php?url_id=237&amp;entry_id=78" title="http://www.phpunit.de/ticket/526"  onmouseover="window.status='http://www.phpunit.de/ticket/526';return true;" onmouseout="window.status='';return true;">ticket #526</a>. Essentially I added the ability to do both white list and black list filtering.
</p>

<p>For instance, if you wanted to specify an include filter you can do the following:</p>

<div class="php" style="text-align: left"><br /><span style="color: #000000; font-weight: bold;">&lt;?php</span> <br /><span style="color: #808080; font-style: italic;">//... </span><br /><br /><span style="color: #0000ff;">$filteredDataSet</span> = <span style="color: #000000; font-weight: bold;">new</span> PHPUnit_Extensions_Database_DataSet_DataSetFilter<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$dataSet</span><span style="color: #66cc66;">&#41;</span>;<br /><br /><span style="color: #0000ff;">$filteredDataSet</span>-&gt;<span style="color: #006600;">addIncludeTables</span><span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'table1'</span>, <span style="color: #ff0000;">'table3'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>; <br /><span style="color: #0000ff;">$filteredDataSet</span>-&gt;<span style="color: #006600;">setIncludeColumnsForTable</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'table1'</span>, <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'column1'</span>, <span style="color: #ff0000;">'column2'</span>, <span style="color: #ff0000;">'column3'</span>, <span style="color: #ff0000;">'column4'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>; <br /><span style="color: #0000ff;">$filteredDataSet</span>-&gt;<span style="color: #006600;">setIncludeColumnsForTable</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'table3'</span>, <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'column9'</span>, <span style="color: #ff0000;">'column10'</span>, <span style="color: #ff0000;">'column11'</span>, <span style="color: #ff0000;">'column12'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;<br /><br /><span style="color: #808080; font-style: italic;">//... </span><br /><span style="color: #000000; font-weight: bold;">?&gt;</span><br />&#160;</div>

<p>I have also deprecated passing the filter to the constructor. The reason for this is that I would like to begin adding a few more features to the filter and the current method of passing the parameters on the constructor would be unintuitive for these planned features. Basically I think it was a mistake for me to allow the passing of filter data on the constructor to begin with. I anticipate the current method working up to PHPUnit 4.0 but it will not be expanded on and will be removed either in PHPUnit 4 or in a release soon after that.
</p>

<p>So, for exclude filters, instead of specifying them in the constructor, the new method will be:</p>

<div class="php" style="text-align: left"><br /><span style="color: #000000; font-weight: bold;">&lt;?php</span> <br /><span style="color: #808080; font-style: italic;">//...</span><br /><br /><span style="color: #0000ff;">$filteredDataSet</span> = <span style="color: #000000; font-weight: bold;">new</span> PHPUnit_Extensions_Database_DataSet_DataSetFilter<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$dataSet</span><span style="color: #66cc66;">&#41;</span>;<br /><br /><span style="color: #0000ff;">$filteredDataSet</span>-&gt;<span style="color: #006600;">addExcludeTables</span><span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'table2'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>; <br /><span style="color: #0000ff;">$filteredDataSet</span>-&gt;<span style="color: #006600;">setExcludeColumnsForTable</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'table1'</span>, <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'table1_id'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>; <br /><span style="color: #0000ff;">$filteredDataSet</span>-&gt;<span style="color: #006600;">setExcludeColumnsForTable</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'table3'</span>, <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'table3_id'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;<br /><br /><span style="color: #808080; font-style: italic;">//... </span><br /><span style="color: #000000; font-weight: bold;">?&gt;</span><br />&#160;</div>

<p>While you can't mix include and exclude filters for tables (wouldn't make sense right now) you CAN do this for table columns of separate tables:</p>

<div class="php" style="text-align: left"><br /><span style="color: #000000; font-weight: bold;">&lt;?php</span> <br /><span style="color: #808080; font-style: italic;">//...</span><br /><br /><span style="color: #0000ff;">$filteredDataSet</span> = <span style="color: #000000; font-weight: bold;">new</span> PHPUnit_Extensions_Database_DataSet_DataSetFilter<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$dataSet</span><span style="color: #66cc66;">&#41;</span>;<br /><br /><span style="color: #0000ff;">$filteredDataSet</span>-&gt;<span style="color: #006600;">addIncludeTables</span><span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'table1'</span>, <span style="color: #ff0000;">'table3'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>; <br /><span style="color: #0000ff;">$filteredDataSet</span>-&gt;<span style="color: #006600;">setExcludeColumnsForTable</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'table1'</span>, <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'table1_id'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>; <br /><span style="color: #0000ff;">$filteredDataSet</span>-&gt;<span style="color: #006600;">setIncludeColumnsForTable</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'table3'</span>, <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'column9'</span>, <span style="color: #ff0000;">'column10'</span>, <span style="color: #ff0000;">'column11'</span>, <span style="color: #ff0000;">'column12'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;<br /><br /><span style="color: #808080; font-style: italic;">//... </span><br /><span style="color: #000000; font-weight: bold;">?&gt;</span><br />&#160;</div>

<p>Some future features I plan on adding include, global column includes/excludes and wild cards. Anyhow, hope this is useful for someone.</p> 
            </div>
        </content>
        
    </entry>
    <entry>
        <link href="http://www.ds-o.com/archives/77-Why-I-Hate-Singletons.html" rel="alternate" title="Why I Hate Singletons" />
        <author>
            <name>Mike Lively</name>
            <email>nospam@example.com</email>
        </author>
    
        <published>2008-12-23T16:12:40Z</published>
        <updated>2008-12-30T15:45:47Z</updated>
        <wfw:comment>http://www.ds-o.com/wfwcomment.php?cid=77</wfw:comment>
    
        <slash:comments>32</slash:comments>
        <wfw:commentRss>http://www.ds-o.com/rss.php?version=atom1.0&amp;type=comments&amp;cid=77</wfw:commentRss>
    
            <category scheme="http://www.ds-o.com/categories/4-PHP" label="PHP" term="PHP" />
    
        <id>http://www.ds-o.com/archives/77-guid.html</id>
        <title type="html">Why I Hate Singletons</title>
        <content type="xhtml" xml:base="http://www.ds-o.com/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                
<p>
One of the most derided, yet most loved and used patterns is the singleton pattern. Its supporters continually praise its ability to limit instantiation of objects and its opponents continually chastise its tendency to be little more than a glorified global.
</p>

<p>
While programming in many ways boils down to a matter of preference (you can always find someone that agrees with you,) I thought I might as well document my opinion so that those who don't care can have one more thing to ignore.
</p>

<p>Details after the jump</p>
 <br /><a href="http://www.ds-o.com/archives/77-Why-I-Hate-Singletons.html#extended">Continue reading "Why I Hate Singletons"</a>
            </div>
        </content>
        
    </entry>
    <entry>
        <link href="http://www.ds-o.com/archives/76-Book-Review-PHP5-CMS-Framework-Development-by-Martin-Brampton.html" rel="alternate" title="Book Review: PHP5 CMS Framework Development by Martin Brampton" />
        <author>
            <name>Mike Lively</name>
            <email>nospam@example.com</email>
        </author>
    
        <published>2008-12-11T08:22:00Z</published>
        <updated>2008-12-11T21:57:03Z</updated>
        <wfw:comment>http://www.ds-o.com/wfwcomment.php?cid=76</wfw:comment>
    
        <slash:comments>7</slash:comments>
        <wfw:commentRss>http://www.ds-o.com/rss.php?version=atom1.0&amp;type=comments&amp;cid=76</wfw:commentRss>
    
            <category scheme="http://www.ds-o.com/categories/4-PHP" label="PHP" term="PHP" />
    
        <id>http://www.ds-o.com/archives/76-guid.html</id>
        <title type="html">Book Review: PHP5 CMS Framework Development by Martin Brampton</title>
        <content type="xhtml" xml:base="http://www.ds-o.com/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                
<p><a href="http://www.ds-o.com/exit.php?url_id=226&amp;entry_id=76" title="http://www.packtpub.com/PHP-5-CMS-Framework-Development/book/mid/2705088rxarn"  onmouseover="window.status='http://www.packtpub.com/PHP-5-CMS-Framework-Development/book/mid/2705088rxarn';return true;" onmouseout="window.status='';return true;">PHP5 CMS Framework Development</a> (published by <a href="http://www.ds-o.com/exit.php?url_id=227&amp;entry_id=76" title="http://www.packtpub.com"  onmouseover="window.status='http://www.packtpub.com';return true;" onmouseout="window.status='';return true;">packt publishing</a>) is a a book that offers &quot;Expert insight and practical guidance to creating an efficient, flexible, and robust framework for a PHP5 based content management system.&quot; Upon reading through the book I have found that it gives an excellent case study of <a href="http://www.ds-o.com/exit.php?url_id=229&amp;entry_id=76" title="http://martinbrampton.com/"  onmouseover="window.status='http://martinbrampton.com/';return true;" onmouseout="window.status='';return true;">Martin Brampton's</a> approach to CMS design and implementation. Brampton has been very active in the PHP CMS scene for several years working on widely known projects such as Mambo and Joomla. He is also the creator of Aliro, a newer CMS that had the purpose of utilizing more of the object oriented abilities of PHP5. His experience designing and developing Aliro influenced much of this book.<br /><br />One might be concerned that the ideas in this book are slanted towards how Brampton decided to implement various aspects of Aliro. While it is true that much of the book uses code directly out of Aliro, I feel that he did take the time to make sure he explained the reasons for the design and development decisions he made. This is the feeling that brings me to the overall conclusion that this book is ultimately an in depth case study of the design of Aliro. If you are interested in developing your own CMS framework or have already developed a framework that you would like to extend, then I would highly recommend this book. Even if you do not agree with all of the concepts and ideas presented it does a fantastic job at pointing out potential pitfalls and other items to consider as you work on your CMS.<br /><br />After the jump I give a chapter by chapter breakdown of the book.</p>
 <br /><a href="http://www.ds-o.com/archives/76-Book-Review-PHP5-CMS-Framework-Development-by-Martin-Brampton.html#extended">Continue reading "Book Review: PHP5 CMS Framework Development by Martin Brampton"</a>
            </div>
        </content>
        
    </entry>
    <entry>
        <link href="http://www.ds-o.com/archives/75-Programming-to-Interfaces-Programming-to-Implementations.html" rel="alternate" title="Programming to Interfaces &gt; Programming to Implementations " />
        <author>
            <name>Mike Lively</name>
            <email>nospam@example.com</email>
        </author>
    
        <published>2008-10-15T13:55:15Z</published>
        <updated>2008-10-18T17:55:25Z</updated>
        <wfw:comment>http://www.ds-o.com/wfwcomment.php?cid=75</wfw:comment>
    
        <slash:comments>9</slash:comments>
        <wfw:commentRss>http://www.ds-o.com/rss.php?version=atom1.0&amp;type=comments&amp;cid=75</wfw:commentRss>
    
            <category scheme="http://www.ds-o.com/categories/4-PHP" label="PHP" term="PHP" />
    
        <id>http://www.ds-o.com/archives/75-guid.html</id>
        <title type="html">Programming to Interfaces &gt; Programming to Implementations </title>
        <content type="xhtml" xml:base="http://www.ds-o.com/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                <p>Over the last couple of months there is a concept in object-oriented programming that has been bothering me. This is the notion of 'programming to an interface, not an implementation'. This is a principle I first learned about when reading <a href="http://www.ds-o.com/exit.php?url_id=224&amp;entry_id=75" title="http://www.amazon.com/Design-Patterns-Object-Oriented-Addison-Wesley-Professional/dp/0201633612"  onmouseover="window.status='http://www.amazon.com/Design-Patterns-Object-Oriented-Addison-Wesley-Professional/dp/0201633612';return true;" onmouseout="window.status='';return true;">"Design Patterns: Elements of Reusable Object-Oriented Software"</a> and then further solidified when I read <a href="http://www.ds-o.com/exit.php?url_id=225&amp;entry_id=75" title="http://www.amazon.com/Head-First-Design-Patterns/dp/0596007124"  onmouseover="window.status='http://www.amazon.com/Head-First-Design-Patterns/dp/0596007124';return true;" onmouseout="window.status='';return true;">"Head First Design Patterns"</a>. So when I say "programming to an interface, not an implementation" what exactly do I mean? <a href="http://www.ds-o.com/exit.php?url_id=216&amp;entry_id=75" title="http://www.artima.com/weblogs/index.jsp?blogger=bv"  onmouseover="window.status='http://www.artima.com/weblogs/index.jsp?blogger=bv';return true;" onmouseout="window.status='';return true;">Bill Venners</a> interviewed <a href="http://www.ds-o.com/exit.php?url_id=217&amp;entry_id=75" title="http://en.wikipedia.org/wiki/Erich_Gamma"  onmouseover="window.status='http://en.wikipedia.org/wiki/Erich_Gamma';return true;" onmouseout="window.status='';return true;">Erich Gamma</a> (<a href="http://www.ds-o.com/exit.php?url_id=218&amp;entry_id=75" title="http://www.artima.com/lejava/articles/designprinciplesP.html"  onmouseover="window.status='http://www.artima.com/lejava/articles/designprinciplesP.html';return true;" onmouseout="window.status='';return true;">interview here</a>), one of the "Gang of Four" that co-authored "Design Patterns", for <a href="http://www.ds-o.com/exit.php?url_id=219&amp;entry_id=75" title="http://www.artima.com/index.jsp"  onmouseover="window.status='http://www.artima.com/index.jsp';return true;" onmouseout="window.status='';return true;">Artima Developer</a> during which time he asked the same question. The paraphrased answer is that it helps to limit the introduction of dependencies in your code. Limiting dependencies makes your code easier to test, easier to deploy and easier to change.</p>

<h3>What is the problem?</h3>

<p>You may now asking, "Mike, why does this bother you? It seems like a straightforward concept and I can't imagine that you would disagree with it." Well, you are mostly correct. I don't at all disagree with this principle of reusable object-oriented design. In fact I try to embrace it. The reason it is bothering me is because I don't believe it is really that simple of a concept and it is 'accidentally' ignored by developers quite often.</p>

<h3>Story Time</h3>

<p>So, lets go back a couple of months. As some of you know (and most of you don't) I am currently a lead developer for a loan management platform for <a href="http://www.ds-o.com/exit.php?url_id=220&amp;entry_id=75" title="http://www.sellingsource.com"  onmouseover="window.status='http://www.sellingsource.com';return true;" onmouseout="window.status='';return true;">Selling Source, Inc</a>. Part of my job as a lead developer is to oversee the architecture of our software and make sure it is going in the right direction. One of our projects at the moment is to revamp the search functionality of the software. I'll try not to bore you with too many details (if you want more maybe I'll write TWO blog posts this quarter.) We are denormalizing some of the frequently updated (and obnoxiously wide) tables involved in searching in order to allow moving indexes off of the primary tables in order to improve the update and insert speeds on the primary tables while improving the search speed in the new tables. While doing this we also decided it would be a good time to cleanup some of the code related to searching. One of the ideas was instead of building queries with string concatenations as weare currently doing we could utilize a 'query builder' to create the query. This would allow for more extensibility as responsibility for building the query would reside in an object that could be modified and manipulated much more elegantly than a string.</p>

<p>In the interest of not reinventing the wheel I had one of my developers research other, already existing query builders. The results of his search pointed us to the Zend Framework query builder: <a href="http://www.ds-o.com/exit.php?url_id=221&amp;entry_id=75" title="http://framework.zend.com/apidoc/core/Zend_Db/Select/Zend_Db_Select.html"  onmouseover="window.status='http://framework.zend.com/apidoc/core/Zend_Db/Select/Zend_Db_Select.html';return true;" onmouseout="window.status='';return true;">Zend_DB_Select</a>. Now I did have a few requirements in my head for what I would like to see out of this external query builder. This first one being that I wanted it to be stand alone. I did not want to have to bring in a bunch of extra baggage that I simply did not need. I was not looking for a framework, we already have one of those. I was looking for a component that we could plug into our existing framework.</p>

<p>Therein lied the problem with Zend_DB_Select. If you look at Zend_DB_Select from the view point of "What are its dependencies?" You will quickly find that there is a class wide dependency on <a href="http://www.ds-o.com/exit.php?url_id=222&amp;entry_id=75" title="http://framework.zend.com/apidoc/core/Zend_Db/Adapter/Zend_Db_Adapter_Abstract.html"  onmouseover="window.status='http://framework.zend.com/apidoc/core/Zend_Db/Adapter/Zend_Db_Adapter_Abstract.html';return true;" onmouseout="window.status='';return true;">Zend_Db_Adapter_Abstract</a>. This is an abstract class that essentially acts as a wrapper for the existing PHP database libraries. It provides a wealth of functionality including a unified interface for database interaction, a hook for a query profiler and some utility functions. I am sure in the grand scheme of the Zend Framework this is a very good and worth while class. However I would to make the argument that there is no reason for Zend_DB_Select to have a dependency on this class and the basis for that argument is an aspect of limiting your dependencies by truly programming to an interface.</p>

<h3>How We Can Use It</h3>

<p>So there are four ways that I would be able to use Zend_Db_Select as it is implemented right now.</p>

<ol>
<li>Change my code to utilize Zend's db adapter for all of its connection needs. While the Zend adapter may well be better than the one I am using, I already have established use in over 100,000 lines of code of our own database connection classes. I just need to redesign our search code. Replacing all uses would be completely outside of the scope which in the business world is a bad place to be.</li>

<li>Create a Zend_DB_Adapter instance whenever you want to use the query builder. This is not a very good option either. We are using InnoDB for our database. InnoDB performance suffers pretty much linearly with the number of open connections. Creating two connections to the same database on most every request is just a bad idea.</li>

<li>Create an extension of Zend_DB_Adapter that decorates (wraps) an existing instance of my connection object. Of all three options so far this one is the most appealing. That being said I still do not think it is ideal. The database connection libraries we use at my office is much more encapsulated than the Zend counterpart. There is alot that Zend_DB_Adapter does that is not in our connection class, it is spread out to other classes such that it can be loaded on an as needed basis. This would make it take some time to write an adapter and would still necessitate us bringing Zend_DB_Adapter into our code base for basically a single purpose.</li>

<li>Modify Zend_Db_Select to remove the dependency on Zend_Db_Adapter_Abstract. This is actually the path we are currently exploring. The large downside to this is that we won't be able to quickly get the upgrades or bug fixes from Zend Framework. However I am not too concerned. What we need this class to do is significantly more limited than its current feature set so we will be able to shrink it significantly and with less code comes more stability or at the very least fewer things that could break.</li>
</ol>

<p>We have identified that this dependency on Zend_Db_Adapter_Abstract is going to cause us all sorts of greif. Lets look at WHY Zend_DB_Select is dependent on Zend_Db_Adapter_Abstract. First, Zend_DB_Select is given the Zend_Db_Adapter_Abstract instance in the constructor. It is then set to the protected member variable $_adapter. So, lets see what all in $_adapter is called throughout the class:</p>

<ul>
<li><b>quoteInto():</b> 3</li>
<li><b>quoteIdentifier():</b> 6</li>
<li><b>quoteTableAs():</b> 1</li>
<li><b>quoteColumnAs():</b> 3</li>
<li><b>limit():</b> 1</li>
<li><b>query():</b> 1</li>
<li><b>getFetchMode():</b> 1</li>
</ul>

<p>The first thing you will notice is that all but 3 calls are to methods that are responsible for quoting an object. Now, indulge me for a moment and imagine that those were the only calls made. Why should I need a full fledged connection adapter object to perform quoting? I do realize that some quoting operations depend on the connection (character set, rdbms differences, etc.) But this should not mean that I <b>have</b> to use (in some form or another) Zend's database adapters. I don't want to use it. Mine works extremely well for what I want to do and I am already using it throughout my application.</p>

<h3>Moving Closer to Integration Utopia</h3>

<p>Now, in a dream world Zend_Db_Select would already be in a state that we could easily plug it into our code without having to go with one of the above four options. What if we created an interface that had a public method for each of the Zend_DB_Adapter_Abstract quote methods? It would look something like this:</p>

<div class="php" style="text-align: left"><br /><span style="color: #000000; font-weight: bold;">&lt;?php</span><br /><br />interface Zend_DB_IQuoter<br /><span style="color: #66cc66;">&#123;</span><br />&#160; &#160; &#160; &#160; public <span style="color: #000000; font-weight: bold;">function</span> quote<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$value</span>, <span style="color: #0000ff;">$type</span> = <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span>;<br />&#160; &#160; &#160; &#160; public <span style="color: #000000; font-weight: bold;">function</span> quoteInto<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$text</span>, <span style="color: #0000ff;">$value</span>, <span style="color: #0000ff;">$type</span> = <span style="color: #000000; font-weight: bold;">null</span>, <span style="color: #0000ff;">$count</span> = <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span>;<br />&#160; &#160; &#160; &#160; public <span style="color: #000000; font-weight: bold;">function</span> quoteIdentifier<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$ident</span>, <span style="color: #0000ff;">$auto</span>=<span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">&#41;</span>;<br />&#160; &#160; &#160; &#160; public <span style="color: #000000; font-weight: bold;">function</span> quoteColumnAs<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$ident</span>, <span style="color: #0000ff;">$alias</span>, <span style="color: #0000ff;">$auto</span>=<span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">&#41;</span>;<br />&#160; &#160; &#160; &#160; public <span style="color: #000000; font-weight: bold;">function</span> quoteTableAs<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$ident</span>, <span style="color: #0000ff;">$alias</span> = <span style="color: #000000; font-weight: bold;">null</span>, <span style="color: #0000ff;">$auto</span>=<span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">&#41;</span>;<br /><span style="color: #66cc66;">&#125;</span><br /><br /><span style="color: #000000; font-weight: bold;">?&gt;</span><br />&#160;</div>

<p>The Zend_DB_Adapter could easily be made to implement this interface (you would just have to add the interface to the class definition.) Then I could change the type hint in Zend_Db_Select's constructor to use the new interface. So how would this help my cause? Well now I have a new option. This new option would be to create an implementation of this interface that worked with my existing connection objects. This would be significantly easier than alternative 3. The interface would be well defined and significantly smaller than the Zend_Db_Adapter_Abstract class.</p>

<p>From a design standpoint this interface makes more sense too. The only thing we care about is quoting. So why not specify (via the constructor type hint) that this is really the only thing we are concerned with. It would make the true dependencies of our class much more transparent. From an extensibility and flexibility stand point this is very useful.</p>

<p>So, we still have those other pesky three calls to the Zend_Db_Adapter_Abstract class.</p>

<ul>
<li><b>limit():</b> 1</li>
<li><b>query():</b> 1</li>
<li><b>getFetchMode():</b> 1</li>
</ul>

<p>Lets explore why these are there.</p>

<p>The reason why limit() is being used is because different database platforms have different ways to specify limits and offsets. For MySQL you can use LIMIT <N>, LIMIT <N>, <N> or LIMIT <N> OFFSET <N>. Oracle from what I understand doesn't implement limits at all. Now one thing that I find uniquely curious is that all of a sudden in Zend they have moved query building back into their adapters in a very explicit way. So what would I do? Well, since we have already established that quoting really should be connection specific and we have no identified that limits are really connection specific (by virtue of being RDBMS specific) then we could make a small change to the interface above. The first would be to add the limit() function. The next would be to change the name. It is no longer a 'Quoter' it is now essentially performing all connection specific alterations for our queries. So lets try out the name Zend_Db_IQueryModifier. Now before you go yelling at me for that name, let me first say that I suck at class naming. You are more than welcome to 'insert your name here'.</p>

<p>This leaves us with a finding home for query and getFetchMode(). I have a problem with these two method calls. They are both used on a method called query() in the Zend_Db_Select. For the kind of object I am looking for, I don't think these should be here. We already have a class that is responsible for executing queries. Instead of calling 'query()' on my query builder object I would much rather pass that object to my adapter. Which is actually what the Zend Framework implementation of this method does. If you do not want to make your adapter dependent on the query object (which I personally would not want to do either) you could have the Zend_Db_Select have a method to return the query. (Zend_Db_Select implements __toString()).</p>

<p>With these changes I (or anyone for the matter) could use the Zend_Db_Select class completely stand alone with no need for any additional, non-exception Zend classes.</p>

<h3>I am a Lover, Not a Hater (Oh and I'm Stupid Too)</h3>

<p>It is not my purpose to pick on Zend Framework. I am confident that they are not the only example of not clearly thinking through dependencies and I am equally confident that many people find Zend Framework to be very useful for their needs. They just happened to have an easy real world example of ways that code can be made better and I happened to have to spend a significant amount of time inspecting the code for reasons other than writing an article. Just to prove I am not trying to point the finger I have an example that is arguably worse than the one above and it is in code that I wrote. A <a href="http://www.ds-o.com/exit.php?url_id=223&amp;entry_id=75" title="http://www.phpunit.de/ticket/554"  onmouseover="window.status='http://www.phpunit.de/ticket/554';return true;" onmouseout="window.status='';return true;">bug was recently opened for PHPUnit</a> that essentially asked me why I had type hints for the default database connection class of the database extension in several of my files. There was no real need for this. I wasn't as interested in a wrapped version of the class as I was in simply retrieving meta data. In fact to make things even worse I ALREADY HAD an interface for this data. I just simply did not use it in this case. It was a terrible oversight of mine and is an example of even when you know better these kind of dependencies can slip by. If you would like more details I can outline them in another post.</p>

<h3>I am Almost Done</h3>

<p>So, at the expense of ending this ridiculously long blog posting lets go back to the Erich Gamma interview. In the spirit of programming to interfaces, not implementations, I believe you should limit dependencies to responsibilities not complete classes. If a class truly has only one responsibility, then it is probably okay to use that class name as the type hint. If a class has multiple responsibilities and you have deemed it necessary than I would strongly recommend you create interfaces to indicate the public methods for those responsibilities and use those in your type hints as appropriate.</p>

<p>Now, if you read through the entire interview (and I suggest you do) you will notice that Erich makes some points that might on the surface seem to contradict what I am saying. Erich states "An abstract class is good as well. In fact, an abstract class gives you more flexibility when it comes to evolution. You can add new behavior without breaking clients." This is a very valid point. He does however go on to state, "As always there is a trade-off, an interface gives you freedom with regard to the base class, an abstract class gives you the freedom to add new methods later." So you do have a decision to make. My issue with Zend_Db_Select turned out to be that the dependency in code was deeper than it needed to be. Sometimes you will have a dependency on an abstract class that will be perfectly fine. So long as you keep responsibilities to a minimum via composition among other means (which the second point in that interview helps with.) Then you should find it very easy to program to interfaces.</p> 
            </div>
        </content>
        
    </entry>
    <entry>
        <link href="http://www.ds-o.com/archives/74-2008-DC-PHP-Conference-Advanced-PHPUnit-Testing.html" rel="alternate" title="2008 DC PHP Conference - Advanced PHPUnit Testing" />
        <author>
            <name>Mike Lively</name>
            <email>nospam@example.com</email>
        </author>
    
        <published>2008-06-04T13:55:41Z</published>
        <updated>2008-06-06T13:35:39Z</updated>
        <wfw:comment>http://www.ds-o.com/wfwcomment.php?cid=74</wfw:comment>
    
        <slash:comments>2</slash:comments>
        <wfw:commentRss>http://www.ds-o.com/rss.php?version=atom1.0&amp;type=comments&amp;cid=74</wfw:commentRss>
    
            <category scheme="http://www.ds-o.com/categories/9-PHP-Testing" label="PHP Testing" term="PHP Testing" />
    
        <id>http://www.ds-o.com/archives/74-guid.html</id>
        <title type="html">2008 DC PHP Conference - Advanced PHPUnit Testing</title>
        <content type="xhtml" xml:base="http://www.ds-o.com/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                
<p>And here are the advanced PHPUnit slides!</p>
<div id="__ss_446619" style="width: 425px; text-align: left;"><object width="425" height="355" style="margin: 0px;"><param value="http://static.slideshare.net/swf/ssplayer2.swf?doc=advanced-php-unit-testing2-1212587249704441-9" name="movie" /><param value="true" name="allowFullScreen" /><param value="always" name="allowScriptAccess" /><embed width="425" height="355" allowfullscreen="true" allowscriptaccess="always" type="application/x-shockwave-flash" src="http://static.slideshare.net/swf/ssplayer2.swf?doc=advanced-php-unit-testing2-1212587249704441-9" /></object><div style="font-size: 11px; font-family: tahoma,arial; height: 26px; padding-top: 2px;"><a href="http://www.ds-o.com/exit.php?url_id=211&amp;entry_id=74" title="http://www.slideshare.net/?src=embed"  onmouseover="window.status='http://www.slideshare.net/?src=embed';return true;" onmouseout="window.status='';return true;"><img alt="SlideShare" style="border: 0px none ; margin-bottom: -5px;" src="http://static.slideshare.net/swf/logo_embd.png" /></a> | <a title="View Advanced PHPUnit Testing on SlideShare" href="http://www.ds-o.com/exit.php?url_id=212&amp;entry_id=74"  onmouseover="window.status='http://www.slideshare.net/mjlivelyjr/advanced-phpunit-testing?src=embed';return true;" onmouseout="window.status='';return true;">View</a> | <a href="http://www.ds-o.com/exit.php?url_id=213&amp;entry_id=74" title="http://www.slideshare.net/upload?src=embed"  onmouseover="window.status='http://www.slideshare.net/upload?src=embed';return true;" onmouseout="window.status='';return true;">Upload your own</a></div></div> 
            </div>
        </content>
        
    </entry>
    <entry>
        <link href="http://www.ds-o.com/archives/73-2008-DC-PHP-Conference-Automated-Unit-Testing.html" rel="alternate" title="2008 DC PHP Conference - Automated Unit Testing" />
        <author>
            <name>Mike Lively</name>
            <email>nospam@example.com</email>
        </author>
    
        <published>2008-06-04T13:52:32Z</published>
        <updated>2008-06-05T06:02:58Z</updated>
        <wfw:comment>http://www.ds-o.com/wfwcomment.php?cid=73</wfw:comment>
    
        <slash:comments>2</slash:comments>
        <wfw:commentRss>http://www.ds-o.com/rss.php?version=atom1.0&amp;type=comments&amp;cid=73</wfw:commentRss>
    
            <category scheme="http://www.ds-o.com/categories/9-PHP-Testing" label="PHP Testing" term="PHP Testing" />
    
        <id>http://www.ds-o.com/archives/73-guid.html</id>
        <title type="html">2008 DC PHP Conference - Automated Unit Testing</title>
        <content type="xhtml" xml:base="http://www.ds-o.com/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                <p>As promised here are my automated unit testing slides for the 2008 DC PHP conference.</p>
<div style="width:425px;text-align:left" id="__ss_446614"><object style="margin:0px" width="425" height="355"><param name="movie" value="http://static.slideshare.net/swf/ssplayer2.swf?doc=automated-unit-testing-1212587126813053-9"/><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed src="http://static.slideshare.net/swf/ssplayer2.swf?doc=automated-unit-testing-1212587126813053-9" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object><div style="font-size:11px;font-family:tahoma,arial;height:26px;padding-top:2px;"><a href="http://www.ds-o.com/exit.php?url_id=208&amp;entry_id=73" title="http://www.slideshare.net/?src=embed"  onmouseover="window.status='http://www.slideshare.net/?src=embed';return true;" onmouseout="window.status='';return true;"><img src="http://static.slideshare.net/swf/logo_embd.png" style="border:0px none;margin-bottom:-5px" alt="SlideShare"/></a> | <a href="http://www.ds-o.com/exit.php?url_id=209&amp;entry_id=73"  onmouseover="window.status='http://www.slideshare.net/mjlivelyjr/automated-unit-testing?src=embed';return true;" onmouseout="window.status='';return true;" title="View Automated Unit Testing on SlideShare">View</a> | <a href="http://www.ds-o.com/exit.php?url_id=210&amp;entry_id=73" title="http://www.slideshare.net/upload?src=embed"  onmouseover="window.status='http://www.slideshare.net/upload?src=embed';return true;" onmouseout="window.status='';return true;">Upload your own</a></div></div>
 
            </div>
        </content>
        
    </entry>
    <entry>
        <link href="http://www.ds-o.com/archives/72-DC-PHP.html" rel="alternate" title="DC PHP" />
        <author>
            <name>Mike Lively</name>
            <email>nospam@example.com</email>
        </author>
    
        <published>2008-05-29T13:24:41Z</published>
        <updated>2008-05-30T13:19:49Z</updated>
        <wfw:comment>http://www.ds-o.com/wfwcomment.php?cid=72</wfw:comment>
    
        <slash:comments>2</slash:comments>
        <wfw:commentRss>http://www.ds-o.com/rss.php?version=atom1.0&amp;type=comments&amp;cid=72</wfw:commentRss>
    
            <category scheme="http://www.ds-o.com/categories/4-PHP" label="PHP" term="PHP" />
    
        <id>http://www.ds-o.com/archives/72-guid.html</id>
        <title type="html">DC PHP</title>
        <content type="xhtml" xml:base="http://www.ds-o.com/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                
<p>I will be flying out this weekend for my first speaking engagement at <a title="The 2008 DC PHP Conference" href="http://www.ds-o.com/exit.php?url_id=206&amp;entry_id=72"  onmouseover="window.status='http://www.dcphpconference.com/';return true;" onmouseout="window.status='';return true;">The 2008 DC PHP Conference</a>. In looking at the speakers list there are a few familiar faces and quite a few new ones so it should be a fun experience all around. I will be giving <a href="http://www.ds-o.com/exit.php?url_id=207&amp;entry_id=72" title="http://www.dcphpconference.com/node/87"  onmouseover="window.status='http://www.dcphpconference.com/node/87';return true;" onmouseout="window.status='';return true;">2.5 talks</a> this year. One on Beginning PHPUnit Testing, another on Advanced PHPUnit Testing and then I will be giving a joint presentation Andrew Minerd, a co-worker of mine, on distributed CLI processes.</p><p>I am fairly excited as this is not only my first time speaking at a PHP conference but it is also the first time I have been to Washington DC. I have a profound respect for the early history of our country and I am looking forward to seeing the some of the landmarks honoring that history. In any case, if you are going to be in DC for the conference be sure to track me down, I shouldn't be too hard to find.</p> <br /><a href="http://www.ds-o.com/archives/72-DC-PHP.html#extended">Continue reading "DC PHP"</a>
            </div>
        </content>
        
    </entry>
    <entry>
        <link href="http://www.ds-o.com/archives/71-Las-Vegas-PHP-Group-Its-Alive.html" rel="alternate" title="Las Vegas PHP Group: It's Alive" />
        <author>
            <name>Mike Lively</name>
            <email>nospam@example.com</email>
        </author>
    
        <published>2008-04-12T13:57:06Z</published>
        <updated>2008-04-12T13:57:06Z</updated>
        <wfw:comment>http://www.ds-o.com/wfwcomment.php?cid=71</wfw:comment>
    
        <slash:comments>3</slash:comments>
        <wfw:commentRss>http://www.ds-o.com/rss.php?version=atom1.0&amp;type=comments&amp;cid=71</wfw:commentRss>
    
            <category scheme="http://www.ds-o.com/categories/4-PHP" label="PHP" term="PHP" />
    
        <id>http://www.ds-o.com/archives/71-guid.html</id>
        <title type="html">Las Vegas PHP Group: It's Alive</title>
        <content type="xhtml" xml:base="http://www.ds-o.com/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                <p>As promised, a couple of days ago the <a href="http://www.ds-o.com/exit.php?url_id=204&amp;entry_id=71"  onmouseover="window.status='http://lvphp.org/';return true;" onmouseout="window.status='';return true;" title="Las Vegas PHP User Group">LV PHP User Group</a> had its first meeting. The purpose of the meeting was to see what kind of interest there was and to gather some ideas for future meetings. We had a pretty good turnout for our first meeting. I think around 20 or so people attended and we mingled and talked amongst ourselves for around 2 hours.</p><p>We are going to be having another meeting in mid to late may. The current plan is that two of us will be doing a couple of short talks, I will be talking about testing and quality assurance. We also talked about getting involved in the<a href="http://www.ds-o.com/exit.php?url_id=205&amp;entry_id=71" title="http://qa.php.net/testfest.php"  onmouseover="window.status='http://qa.php.net/testfest.php';return true;" onmouseout="window.status='';return true;"> PHP TestFest</a> project. The last thing we decided is that the next meeting will be in a 'quieter' environment. PT's Pub worked well for a meet and greet type of meeting but would be a tad loud for any kind of presenting. It also forcluded some people from attending due to the atmosphere.</p><p>When I hear more info about dates I will post it. For those of you that live nowhere near Vegas, maybe you can use us as a way to writeoff a vacation as a business expense? <img src="http://www.ds-o.com/templates/default/img/emoticons/laugh.png" alt=":-D" style="display: inline; vertical-align: bottom;" class="emoticon" /></p>
 
            </div>
        </content>
        
    </entry>
    <entry>
        <link href="http://www.ds-o.com/archives/70-Las-Vegas-PHP-User-Group.html" rel="alternate" title="Las Vegas PHP User Group" />
        <author>
            <name>Mike Lively</name>
            <email>nospam@example.com</email>
        </author>
    
        <published>2008-04-11T01:18:41Z</published>
        <updated>2008-04-17T03:20:43Z</updated>
        <wfw:comment>http://www.ds-o.com/wfwcomment.php?cid=70</wfw:comment>
    
        <slash:comments>9</slash:comments>
        <wfw:commentRss>http://www.ds-o.com/rss.php?version=atom1.0&amp;type=comments&amp;cid=70</wfw:commentRss>
    
            <category scheme="http://www.ds-o.com/categories/4-PHP" label="PHP" term="PHP" />
    
        <id>http://www.ds-o.com/archives/70-guid.html</id>
        <title type="html">Las Vegas PHP User Group</title>
        <content type="xhtml" xml:base="http://www.ds-o.com/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                <p>I am pleased to announce that Las Vegas finally has a <a href="http://www.ds-o.com/exit.php?url_id=199&amp;entry_id=70"  onmouseover="window.status='http://lvphp.org/';return true;" onmouseout="window.status='';return true;" title="Las Vegas PHP User's Group">PHP User Group</a> and our first meeting is...tomorrow. I am pretty excited as I know there is a fairly decent size PHP programmer community in LV, it just hasn't been organized yet. One of my co-workers Ray Lopez is organizing the group and it looks like we'll have a fairly decent size group at our first meeting. If you are from Las Vegas I would encourage you to attend if at all possible! If you are unable to attend then I would highly recommend you still sign up at <a href="http://www.ds-o.com/exit.php?url_id=200&amp;entry_id=70"  onmouseover="window.status='http://php.meetup.com/422/';return true;" onmouseout="window.status='';return true;" title="Las Vegas PHP Meetup">meetup.com</a> so you can keep informed of future meetings.</p><p></p><p>Time: 
Friday, Apr 11, 2008, 4:00 PM<br /><br />Place: <a class="popVenue" href="http://www.ds-o.com/exit.php?url_id=203&amp;entry_id=70" title="http://php.meetup.com/422/venue/?venueId=546845&amp;eventId=7551002"  onmouseover="window.status='http://php.meetup.com/422/venue/?venueId=546845&amp;eventId=7551002';return true;" onmouseout="window.status='';return true;"><br />PT's PUB</a><br />310 E. Warm Springs Rd.<br />Las Vegas, NV 89119<br /><a href="http://www.ds-o.com/exit.php?url_id=202&amp;entry_id=70"  onmouseover="window.status='http://maps.yahoo.com/#mvt=m&amp;lat=36.057116&amp;lon=-115.15835&amp;mag=3&amp;q1=310%20E.%20Warm%20Springs%20Rd%2C%20Las%20Vegas%2C%20NV%2089119';return true;" onmouseout="window.status='';return true;" title="PT's Pub">Directions</a></p> 
            </div>
        </content>
        
    </entry>
    <entry>
        <link href="http://www.ds-o.com/archives/69-Late-Static-Binding-LSB-forward_static_call.html" rel="alternate" title="Late Static Binding (LSB) forward_static_call()" />
        <author>
            <name>Mike Lively</name>
            <email>nospam@example.com</email>
        </author>
    
        <published>2008-04-08T00:19:27Z</published>
        <updated>2008-04-11T01:52:15Z</updated>
        <wfw:comment>http://www.ds-o.com/wfwcomment.php?cid=69</wfw:comment>
    
        <slash:comments>13</slash:comments>
        <wfw:commentRss>http://www.ds-o.com/rss.php?version=atom1.0&amp;type=comments&amp;cid=69</wfw:commentRss>
    
            <category scheme="http://www.ds-o.com/categories/4-PHP" label="PHP" term="PHP" />
    
        <id>http://www.ds-o.com/archives/69-guid.html</id>
        <title type="html">Late Static Binding (LSB) forward_static_call()</title>
        <content type="xhtml" xml:base="http://www.ds-o.com/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                <p>I finally freed up some time to finish some quick tests for some of the late static binding patches I made and one of them finally made it into head.</p><p>The original post I had bringing up this issue was lovingly title <a href="http://www.ds-o.com/exit.php?url_id=190&amp;entry_id=69"  onmouseover="window.status='http://www.digitalsandwich.com/archives/65-Late-static-binding....sorta.html';return true;" onmouseout="window.status='';return true;" title="Late Static Binding Sorta">Late Static Binding...Sorta</a>. Basically the original patch alone did not provide a means to override a method, forward execution to the parent method and still preserve the ability for static:: to be anything meaningful. It would be turned into the syntactic equivelant of self::. I came up with a <a href="http://www.ds-o.com/exit.php?url_id=191&amp;entry_id=69"  onmouseover="window.status='http://www.ds-o.com/archives/68-Late-Static-Binding-Changes-to-parent.html';return true;" onmouseout="window.status='';return true;" title="Late Static Binding - Changes to Parent">few patches</a> to address this. After several rounds of back and forth about the patches the conversation died out with no decision. I finally resurrected the topic and was able to find <a href="http://www.ds-o.com/exit.php?url_id=192&amp;entry_id=69" title="http://news.php.net/php.internals/36208"  onmouseover="window.status='http://news.php.net/php.internals/36208';return true;" onmouseout="window.status='';return true;">concensus for the third patch (forward_static_call())</a>. </p><p>This weekend I wrapped up a few small tests and sent the patch in and it was subsequently <a href="http://www.ds-o.com/exit.php?url_id=193&amp;entry_id=69" title="http://news.php.net/php.cvs/49508"  onmouseover="window.status='http://news.php.net/php.cvs/49508';return true;" onmouseout="window.status='';return true;">pushed to php 5.3 and php 6.0</a>. Now, this is not at all the way I wanted things to work, in all honesty I think the patch is pretty hokey but unfortunately nobody really spoke up in support of the changes I wanted to make to parent:: in regards to LSB. So I thought it far more important to make sure there was a way to make sure static methods could be overridden while ensuring that access to parent methods would be unabated.</p><p>So now, if you want to override a static method and forward execution to the parent class, the safe way (in regards to static inheritance) is shown in Table2 while the (unfortunately) not so safe way is shown in Table1:</p>

<div class="php" style="text-align: left"><br /><span style="color: #000000; font-weight: bold;">&lt;?php</span><br /><br /><span style="color: #000000; font-weight: bold;">class</span> ActiveRecord<br /><span style="color: #66cc66;">&#123;</span><br />&#160; &#160; &#160; &#160; public <a href="http://www.php.net/static"><span style="color: #000066;">static</span></a> funtion loadById<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$id</span>, PDO <span style="color: #0000ff;">$db</span><span style="color: #66cc66;">&#41;</span><br />&#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#123;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #0000ff;">$table</span> = get_called_class<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #0000ff;">$statement</span> = <span style="color: #0000ff;">$db</span>-&gt;<span style="color: #006600;">prepare</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; SELECT * FROM {$table}<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; WHERE {$table}_id = ?<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; "</span><span style="color: #66cc66;">&#41;</span>;<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #0000ff;">$statement</span>-&gt;<span style="color: #006600;">execute</span><span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$id</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #0000ff;">$column_values</span> = $<span style="color: #0000ff;">$statement</span>-&gt;<span style="color: #006600;">fetch</span><span style="color: #66cc66;">&#40;</span>PDO::<span style="color: #006600;">FETCH_ASSOC</span><span style="color: #66cc66;">&#41;</span>;<br /><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$column_values</span><span style="color: #66cc66;">&#41;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#123;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #0000ff;">$ar</span> = <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.php.net/static"><span style="color: #000066;">static</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$db</span><span style="color: #66cc66;">&#41;</span>;<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #0000ff;">$ar</span>-&gt;<span style="color: #006600;">column_values</span> = <span style="color: #0000ff;">$statement</span>-&gt;<span style="color: #006600;">fetch</span><span style="color: #66cc66;">&#40;</span>PDO::<span style="color: #006600;">FETCH_ASSOC</span><span style="color: #66cc66;">&#41;</span>;<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">$ar</span>;<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#125;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #b1b100;">else</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#123;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">FALSE</span>;<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#125;</span><br />&#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#125;</span><br /><span style="color: #66cc66;">&#125;</span><br /><br /><span style="color: #000000; font-weight: bold;">class</span> Table1 extends ActiveRecord<br /><span style="color: #66cc66;">&#123;</span><br />&#160; &#160; &#160; &#160; public <a href="http://www.php.net/static"><span style="color: #000066;">static</span></a> <span style="color: #000000; font-weight: bold;">function</span> loadById<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$id</span>, PDO <span style="color: #0000ff;">$db</span><span style="color: #66cc66;">&#41;</span><br />&#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#123;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #808080; font-style: italic;">/**<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;&#160; * DANGER! the table name will resolve to ActiveRecord<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;&#160; */</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #0000ff;">$ar</span> = parent::<span style="color: #006600;">loadById</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$id</span>, <span style="color: #0000ff;">$db</span><span style="color: #66cc66;">&#41;</span>;<br /><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$ar</span> === <span style="color: #000000; font-weight: bold;">FALSE</span><span style="color: #66cc66;">&#41;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#123;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.php.net/static"><span style="color: #000066;">static</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$db</span><span style="color: #66cc66;">&#41;</span>;<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#125;</span><br />&#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#125;</span><br /><span style="color: #66cc66;">&#125;</span><br /><br /><span style="color: #000000; font-weight: bold;">class</span> Table2 extends ActiveRecord<br /><span style="color: #66cc66;">&#123;</span><br />&#160; &#160; &#160; &#160; public <a href="http://www.php.net/static"><span style="color: #000066;">static</span></a> <span style="color: #000000; font-weight: bold;">function</span> loadById<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$id</span>, PDO <span style="color: #0000ff;">$db</span><span style="color: #66cc66;">&#41;</span><br />&#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#123;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #808080; font-style: italic;">/**<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;&#160; * SAFE WAY! the table name will correctly resolve to Table2<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;&#160; */</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #0000ff;">$ar</span> = forward_static_call<span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'parent'</span>, <span style="color: #ff0000;">'loadById'</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #0000ff;">$id</span>, <span style="color: #0000ff;">$db</span><span style="color: #66cc66;">&#41;</span>;<br /><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$ar</span> === <span style="color: #000000; font-weight: bold;">FALSE</span><span style="color: #66cc66;">&#41;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#123;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.php.net/static"><span style="color: #000066;">static</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$db</span><span style="color: #66cc66;">&#41;</span>;<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#125;</span><br />&#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#125;</span><br /><span style="color: #66cc66;">&#125;</span><br /><br /><span style="color: #000000; font-weight: bold;">?&gt;</span><br />&#160;</div>

<p>This shows an example of the differences between using parent:: and forward_static_call. I really do wish that the behavior of parent:: would just be modified to work like forward_static_call does. It would be alot less awkward and imo closer to what the average oo programmer would expect. I suppose the issue is up for debate if anyone feels like bringing it up on internals, we aren't stuck with it until php 5.3 rolls <img src="http://www.ds-o.com/templates/default/img/emoticons/smile.png" alt=":-)" style="display: inline; vertical-align: bottom;" class="emoticon" />. The <a href="http://www.ds-o.com/exit.php?url_id=196&amp;entry_id=69"  onmouseover="window.status='http://ds-o.com/Patches/lsb.parent-forwarding.v2.php53.patch';return true;" onmouseout="window.status='';return true;" title="LSB parent:: forwarding patch">patch</a> is even available it just needs some more vocal supporters.</p>

<p>In either case at least there is a way around it now...</p> 
            </div>
        </content>
        
    </entry>
    <entry>
        <link href="http://www.ds-o.com/archives/68-Late-Static-Binding-Changes-to-parent.html" rel="alternate" title="Late Static Binding - Changes to parent" />
        <author>
            <name>Mike Lively</name>
            <email>nospam@example.com</email>
        </author>
    
        <published>2007-11-26T06:16:27Z</published>
        <updated>2007-11-29T20:50:57Z</updated>
        <wfw:comment>http://www.ds-o.com/wfwcomment.php?cid=68</wfw:comment>
    
        <slash:comments>5</slash:comments>
        <wfw:commentRss>http://www.ds-o.com/rss.php?version=atom1.0&amp;type=comments&amp;cid=68</wfw:commentRss>
    
            <category scheme="http://www.ds-o.com/categories/4-PHP" label="PHP" term="PHP" />
    
        <id>http://www.ds-o.com/archives/68-guid.html</id>
        <title type="html">Late Static Binding - Changes to parent</title>
        <content type="xhtml" xml:base="http://www.ds-o.com/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                <p>If you have been following the PHP internals list for the last few weeks you probably have seen a discussion concerning the current behaviour of late static binding (lsb) and how it seems to be unnecessarily limited when it comes to inheritance. I first posted about the limitations of the current lsb implementation as it relates to inheritance in <a href="http://www.ds-o.com/exit.php?url_id=180&amp;entry_id=68"  onmouseover="window.status='http://www.digitalsandwich.com/archives/65-Late-static-binding....sorta.html';return true;" onmouseout="window.status='';return true;" title="Late Static Binding...Sorta">Late Static Binding...Sorta</a>. It has since been revived in this thread on the internals mailing list: <a href="http://www.ds-o.com/exit.php?url_id=181&amp;entry_id=68"  onmouseover="window.status='http://marc.info/?l=php-internals&amp;m=119538527824948&amp;w=2';return true;" onmouseout="window.status='';return true;" title="RE: [PHP-DEV] late static binding php6">RE: [PHP-DEV] late static binding php6</a>.</p>

<p>I won't rehash all of the arguments as you can quite easily find out my full thoughts by previous posts and on that mailing list thread. To put it simply I feel that somehow there needs to be a way to call methods in a parent class without losing the ability to reference back to the original called static.</p>

<div class="php" style="text-align: left"><br /><span style="color: #000000; font-weight: bold;">&lt;?php</span><br /><br /><span style="color: #000000; font-weight: bold;">class</span> A<br /><span style="color: #66cc66;">&#123;</span><br />&#160; &#160; &#160; &#160; public <a href="http://www.php.net/static"><span style="color: #000066;">static</span></a> <span style="color: #000000; font-weight: bold;">function</span> test<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><br />&#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#123;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> get_called_class<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>,<span style="color: #ff0000;">"<span style="color: #000099; font-weight: bold;">\n</span>"</span>;<br />&#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#125;</span><br /><span style="color: #66cc66;">&#125;</span><br /><br /><span style="color: #000000; font-weight: bold;">class</span> B<br /><span style="color: #66cc66;">&#123;</span><br />&#160; &#160; &#160; &#160; public <a href="http://www.php.net/static"><span style="color: #000066;">static</span></a> <span style="color: #000000; font-weight: bold;">function</span> test<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><br />&#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#123;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #808080; font-style: italic;">//do additional work ...</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; parent::<span style="color: #006600;">test</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><br />&#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#125;</span><br /><span style="color: #66cc66;">&#125;</span><br /><br />B::<span style="color: #006600;">test</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">//outputs B</span><br /><br /><span style="color: #000000; font-weight: bold;">?&gt;</span><br />&#160;</div>

<p>This (or anything like it) is currently impossible in the current lsb implementation. I spent a bit of my extended weekend preparing three different patches to work around this problem. I just now sent them to the internals mailing list so they can be discussed. You can view this email and get a summary of the patches by viewing <a href="http://www.ds-o.com/exit.php?url_id=184&amp;entry_id=68"  onmouseover="window.status='http://news.php.net/php.internals/33432';return true;" onmouseout="window.status='';return true;" title="[Patch] late binding for parent (and other options)">my recent php-dev posting</a>.</p>

<ul>
	<li><a href="http://www.ds-o.com/exit.php?url_id=185&amp;entry_id=68" title="http://www.digitalsandwich.com/patches/lsb.parent-forwarding.patch"  onmouseover="window.status='http://www.digitalsandwich.com/patches/lsb.parent-forwarding.patch';return true;" onmouseout="window.status='';return true;">lsb.parent-forwarding.patch</a> - Changing the behavior of parent.</li>
	<li><a href="http://www.ds-o.com/exit.php?url_id=186&amp;entry_id=68" title="http://www.digitalsandwich.com/patches/lsb.new-keyword.patch"  onmouseover="window.status='http://www.digitalsandwich.com/patches/lsb.new-keyword.patch';return true;" onmouseout="window.status='';return true;">lsb.new-keyword.patch</a> - Adding a new class keyword.</li>
	<li><a href="http://www.ds-o.com/exit.php?url_id=187&amp;entry_id=68" title="http://www.digitalsandwich.com/patches/lsb.forward_static_call.patch"  onmouseover="window.status='http://www.digitalsandwich.com/patches/lsb.forward_static_call.patch';return true;" onmouseout="window.status='';return true;">lsb.forward_static_call.patch</a> - Adding functions to do my dirty work.</li>
</ul>

<p>All of the above patches are against 5.3. I was having some strange problems with the test suite in php6 so I moved onto php5.3 so I could make sure things weren't breaking on me <img src="http://www.ds-o.com/templates/default/img/emoticons/tongue.png" alt=":-P" style="display: inline; vertical-align: bottom;" class="emoticon" />. If anyone reading this feels as strongly as I do that there should be a way to do this I hope to encourage you to make your thoughts known on PHP-Dev.
</p> 
            </div>
        </content>
        
    </entry>
    <entry>
        <link href="http://www.ds-o.com/archives/67-ZendCon07-Day-1.html" rel="alternate" title="ZendCon07 Day 1" />
        <author>
            <name>Mike Lively</name>
            <email>nospam@example.com</email>
        </author>
    
        <published>2007-10-09T18:02:53Z</published>
        <updated>2007-10-09T18:02:53Z</updated>
        <wfw:comment>http://www.ds-o.com/wfwcomment.php?cid=67</wfw:comment>
    
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://www.ds-o.com/rss.php?version=atom1.0&amp;type=comments&amp;cid=67</wfw:commentRss>
    
            <category scheme="http://www.ds-o.com/categories/4-PHP" label="PHP" term="PHP" />
    
        <id>http://www.ds-o.com/archives/67-guid.html</id>
        <title type="html">ZendCon07 Day 1</title>
        <content type="xhtml" xml:base="http://www.ds-o.com/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                
<p>Day one of the conference is over and everything has gone well so far. I attended the extending PHP session by Wez, Sara, and Marcus. It was alot of review but it was very 

informative and brought up alot of things that I tend to forget frequently. It was also good to find out that Marcus has a pretty decent american impression. In either case I 

have a couple small php extension projects that I am thinking about starting now just to tinker around with some of what they talked about.</p>

<p>I also heard some unconfirmed rumours that database testing was brought a fair amount in the Best Practices tutorial. So if any of you were in that tutorial and have any 

questions track me down.</p>

<p>After the tutorials were finished all of us from the selling source decided to go into San Francisco for some food and what not. We went to the Stinking Rose which billed 

itself as a garlic resteraunt and it certaintly did not dissapoint. We hung around for a while to chit-chat and what not. It is my first time in San Francisco and it pretty much 

has further confirmed that I am definately not a city guy <img src="http://www.ds-o.com/templates/default/img/emoticons/smile.png" alt=":-)" style="display: inline; vertical-align: bottom;" class="emoticon" />.</p>



<p>Today's sessions are underway and thus far I have found myself working the entire time but I plan on stopping that after the current round of sessions is over. I am looking 

forward to going to Give Your Site A Boost With memcached from Ben Ramsey and High Performance PHP &amp; MySQL Scaling Techniques by Eli White. We will also be spending some time 

today setting up the Selling Source booth. We are also sponsering the opening reception tonight in the exhibit hall which I don't really think means anything other than we'll 

have our logo plastered in a few key places which is always nice. Also we are giving away a fairly nifty prize at the end of the conference to a random winner of a little code challenge that we put together.</p>

<p>If any of the fellow conference goers plan on going to the opening reception be sure to track me down and say hello. I think I am going to leave both my laptop and black 

berry so there will be no distractions. I would love to talk to y'all about pretty much anything. <img src="http://www.ds-o.com/templates/default/img/emoticons/tongue.png" alt=":-P" style="display: inline; vertical-align: bottom;" class="emoticon" />.</p>
 
            </div>
        </content>
        
    </entry>
    <entry>
        <link href="http://www.ds-o.com/archives/66-Going-to-ZendCon.html" rel="alternate" title="Going to ZendCon " />
        <author>
            <name>Mike Lively</name>
            <email>nospam@example.com</email>
        </author>
    
        <published>2007-10-05T03:51:01Z</published>
        <updated>2007-10-08T20:32:41Z</updated>
        <wfw:comment>http://www.ds-o.com/wfwcomment.php?cid=66</wfw:comment>
    
        <slash:comments>7</slash:comments>
        <wfw:commentRss>http://www.ds-o.com/rss.php?version=atom1.0&amp;type=comments&amp;cid=66</wfw:commentRss>
    
            <category scheme="http://www.ds-o.com/categories/4-PHP" label="PHP" term="PHP" />
    
        <id>http://www.ds-o.com/archives/66-guid.html</id>
        <title type="html">Going to ZendCon </title>
        <content type="xhtml" xml:base="http://www.ds-o.com/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                <p>I will be leaving for ZendCon on Sunday. This will be my first zend con and I am really looking forward to going. I was hoping to speak at the conference about refactoring and database testing but alas it wasn't meant to be <img src="http://www.ds-o.com/templates/default/img/emoticons/smile.png" alt=":-)" style="display: inline; vertical-align: bottom;" class="emoticon" />. I figure it gives me more time to enjoy everyone else's talks and I can also meet the other attendees without the impending doom of everyone in a room paying attention to me.</p><p>I will be attending the conference with a sizable group of co-workers from <a href="http://www.ds-o.com/exit.php?url_id=178&amp;entry_id=66" title="http://sellingsource.com"  onmouseover="window.status='http://sellingsource.com';return true;" onmouseout="window.status='';return true;">The Selling Source</a> and will be spending some time in our booth in the exhibit hall. If any of you would like to discuss unit testing, late static binding, or what not please come track me down. I am very interested to talk with anyone that may have checked out the <a href="http://www.ds-o.com/exit.php?url_id=179&amp;entry_id=66" title="http://phpunit.de"  onmouseover="window.status='http://phpunit.de';return true;" onmouseout="window.status='';return true;">PHPUnit</a> Database extension. I have a small list of features that I am hoping to add shortly and would love to hear about any other features people may be looking for.</p> 
            </div>
        </content>
        
    </entry>
    <entry>
        <link href="http://www.ds-o.com/archives/65-Late-static-binding....sorta.html" rel="alternate" title="Late static binding....sorta :/" />
        <author>
            <name>Mike Lively</name>
            <email>nospam@example.com</email>
        </author>
    
        <published>2007-09-27T02:08:31Z</published>
        <updated>2007-10-02T14:36:50Z</updated>
        <wfw:comment>http://www.ds-o.com/wfwcomment.php?cid=65</wfw:comment>
    
        <slash:comments>18</slash:comments>
        <wfw:commentRss>http://www.ds-o.com/rss.php?version=atom1.0&amp;type=comments&amp;cid=65</wfw:commentRss>
    
            <category scheme="http://www.ds-o.com/categories/4-PHP" label="PHP" term="PHP" />
    
        <id>http://www.ds-o.com/archives/65-guid.html</id>
        <title type="html">Late static binding....sorta :/</title>
        <content type="xhtml" xml:base="http://www.ds-o.com/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                <p>The good news is late static binding has been introduced into head and looks like it will be merged into 5.3 before it is released. The horrible news is I really don't think the patch went as far as it needs to.</p>

<p>If you look at the <a href="http://www.ds-o.com/exit.php?url_id=175&amp;entry_id=65"  onmouseover="window.status='http://www.ds-o.com/archives/53-Late-Static-Binding-in-PHP.html';return true;" onmouseout="window.status='';return true;" title="Late Static Binding In PHP">original posts</a> that cropped up about a year and a half ago the whole purpose of late static binding was to allow the same kind of  flexibility provided by inheritance of standard class methods for static methods, properties, and constants. This wouldn't really open the door for any grandios, new kind of applications, it would just allow a new way to code libraries the most prominant example being an Active Record Library.</p>

<p>This is now possible, however I think there is a very unfortunate limitation that I brought up a few times on the Internals mailing list to apparently no avail. The problem is with the fact that static will ALWAYS return the 'resolved' name of the class used to call the current function. So, imagine the following method:</p>

<div class="php" style="text-align: left"><br /><span style="color: #000000; font-weight: bold;">class</span> Foo<br /><span style="color: #66cc66;">&#123;</span><br />&#160; &#160; &#160; &#160; <span style="color: #808080; font-style: italic;">//...</span><br /><br />&#160; &#160; &#160; &#160; <a href="http://www.php.net/static"><span style="color: #000066;">static</span></a> public <span style="color: #000000; font-weight: bold;">function</span> test<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><br />&#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#123;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #b1b100;">return</span> <a href="http://www.php.net/static"><span style="color: #000066;">static</span></a>::<span style="color: #0000ff;">$some_property</span>;<br />&#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#125;</span><br /><br />&#160; &#160; &#160; &#160; <span style="color: #808080; font-style: italic;">//...</span><br /><span style="color: #66cc66;">&#125;</span><br /><br /><span style="color: #000000; font-weight: bold;">class</span> Bar extends Foo<br /><span style="color: #66cc66;">&#123;</span><br /><span style="color: #66cc66;">&#125;</span><br />&#160;</div>

<p>If you call test using Foo::test() then static:: will resolve to the 'Foo' class. If you call it using Bar::test() then static:: will resolve to 'Bar'. This is correct and works well for simple inheritance. However things start taking a downward turn the more you use inheritance. Consider the following change to Bar and the addition of a new class Bar_Child:</p>

<div class="php" style="text-align: left"><br /><span style="color: #000000; font-weight: bold;">class</span> Foo<br /><span style="color: #66cc66;">&#123;</span><br />&#160; &#160; &#160; &#160; <span style="color: #808080; font-style: italic;">//...</span><br /><br />&#160; &#160; &#160; &#160; <a href="http://www.php.net/static"><span style="color: #000066;">static</span></a> public <span style="color: #000000; font-weight: bold;">function</span> test<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><br />&#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#123;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #b1b100;">return</span> <a href="http://www.php.net/static"><span style="color: #000066;">static</span></a>::<span style="color: #0000ff;">$some_property</span>;<br />&#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#125;</span><br /><br />&#160; &#160; &#160; &#160; <span style="color: #808080; font-style: italic;">//...</span><br /><span style="color: #66cc66;">&#125;</span><br /><br /><span style="color: #000000; font-weight: bold;">class</span> Bar extends Foo<br /><span style="color: #66cc66;">&#123;</span><br />&#160; &#160; &#160; &#160; <a href="http://www.php.net/static"><span style="color: #000066;">static</span></a> public <span style="color: #000000; font-weight: bold;">function</span> test<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><br />&#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#123;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #808080; font-style: italic;">// Do some work specific to Bar</span><br /><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #b1b100;">return</span> parent::<span style="color: #006600;">test</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />&#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#125;</span><br /><span style="color: #66cc66;">&#125;</span><br /><br /><span style="color: #000000; font-weight: bold;">class</span> Bar_Child extends Bar<br /><span style="color: #66cc66;">&#123;</span><br /><span style="color: #66cc66;">&#125;</span><br />&#160;</div>

<p>Now, calling Foo::test() will again result in static:: being bound to 'Foo'. However, due to the fact that parent:: will resolve to Foo:: that means the call Bar::test() will now result in static:: being bound to 'Foo'. Bar_Child::test() will do exactly the same thing, static:: will again be bound to 'Foo'. This is incredibly inflexible and in my opinion this is the exact problem that 'late static binding' is SUPPOSED to fix.</p>

<p>There are a couple of ways to fix this that I can think of right now, unfortunately nobody on list seems very motivated to explore any compromises. The two ways that come to mind immediately are either setting the behavior of parent:: such that it forwards the calling class through the next function call. So in the example above, calling Bar::test() will still result in calling Foo::test() however it will not 'reset' the calling class so that static:: will still resolve to 'Bar::', likewise Bar_Child::test() will result in static:: being bound to 'Bar_Child'.</p>

<p>The second alternative is introducing another scope. I have no clue what this scope would be called, but it would basically implement the functionality I just described for parent:: above but would do it using a new keyword so parent:: could remain the same.</p>

<p>Dmitry Stogov mentioned my first alternative on the list however he also included this functionality for the self:: scope which I could see causing some serious problems. In either case, I am thankful that the functionality has started to make its way in, but I can't help but think that myself and some other early proponents of the functionality are getting completely shafted.</p>
 
            </div>
        </content>
        
    </entry>

</feed>