<?xml version="1.0"?>
<rss version="2.0">
  <channel>
    <title>PHPDeveloper.org</title>
    <link>http://www.phpdeveloper.org</link>
    <description>Up-to-the Minute PHP News, views and community</description>
    <language>en-us</language>
    <pubDate>Sat, 25 May 2013 18:20:44 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Michael Nitschinger: A Journey on Avoiding Nulls in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/19210</guid>
      <link>http://www.phpdeveloper.org/news/19210</link>
      <description><![CDATA[<p>
<i>Michael Nitschinger</i> has written up a post looking at <a href="http://nitschinger.at/A-Journey-on-Avoiding-Nulls-in-PHP">avoiding nulls in your applications</a> in favor of a better kind of value handling - the introduction of "<a href="http://code.google.com/p/guava-libraries/wiki/UsingAndAvoidingNullExplained">Optional</a>" handling.
</p>
<blockquote>
While every developer has kind of accepted their existence, they are suddenly there when we'd desperately need them to not show up. How often did you writeif($obj === null) in your PHP code? Can't there be a better, more elegant and fault-tolerant solution to the problem?
</blockquote>
<p>
His solution is to create a PHP version of this "Optional" functionality (via an abstract class) that allows some evaluation of the returned value from method calls on the object. Methods like "isPresent", "getOrElse", "of" and "fromNullable"  make it easier to work with null values instead of just the triple-equals checking. He includes not only the code for the classes you'll need to implement it but examples of it in use - an "Optional" abstract class and two child classes, "Present" and "Absent".
</p>]]></description>
      <pubDate>Wed, 20 Feb 2013 12:17:39 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Anthony Ferrara's Blog: IteratorIterator - PHP Inconsistencies And WTFs]]></title>
      <guid>http://www.phpdeveloper.org/news/17071</guid>
      <link>http://www.phpdeveloper.org/news/17071</link>
      <description><![CDATA[<p>
<i>Anthony Ferrara</i> has a new post to his blog sharing some <a href="http://blog.ircmaxell.com/2011/10/iteratoriterator-php-inconsistencies.html">inconsistencies with iterators</a> that he discovered as discussed with a <a href="http://twitter.com/#!/go_oh">fellow developer</a> - why some iterators only accept Iterator arguments and others don't.
</p>
<blockquote>
We were talking about why some of the SPL Iterators accept only an Iterator as the constructor argument (Such as <a href="http://us2.php.net/manual/en/class.limititerator.php">LimitIterator</a>), and others accept either an Iterator or an IteratorAggregate as the argument (Such as <a href="http://us2.php.net/manual/en/class.iteratoriterator.php">IteratorIterator</a>).  Feeling that this would be a useful feature to add (having all of them accept an IteratorAggregate), I opened up the PHP source and started looking at how hard of a change this would be.  What I found was... Interesting...
</blockquote>
<p>
He shares some of the C code he came across in his investigation including a "WTF" moment when he found a <a href="http://lxr.php.net/xref/PHP_5_3/ext/spl/spl_iterators.c#1418">case statement for DIT_IteratorIterator</a> in a constructor. Because of some of the logic in this constructor, the inputted iterator is "cast down" to a class. This is shown in a few code examples comparing simple iteration objects and arrays and how it seems to be able to bypass class inheritance to use methods from other classes.
</p>]]></description>
      <pubDate>Tue, 01 Nov 2011 12:58:07 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Lorna Mitchell's Blog: Stopping CodeIgniter from Escaping SQL]]></title>
      <guid>http://www.phpdeveloper.org/news/13930</guid>
      <link>http://www.phpdeveloper.org/news/13930</link>
      <description><![CDATA[<p>
In <a href="http://joind.in">a project</a> she's been working on <i>Lorna Mitchell</i> was frustrated with something the <a href="http://codeigniter.com">CodeIgniter</a> framework does natively - escape SQL statements done through the databaase layer's "select()" method. Thankfully, there was a simple fix to turn this behavior off.
</p>
<blockquote>
I've been getting increasingly impatient with its tendency to try to escape my SQL code for me - this is a really useful default feature but it seems to assume I don't know what I'm doing and so it puts backticks all over perfectly acceptable SQL code, very annoying!
</blockquote>
<p>
Thanks to <a href="http://twitter.com/damiangostomski/statuses/8209882657">a reply on twitter from damiangostomski</a> to her frustrations she found the optional second parameter you can give the "select()" method, a boolean that tells it whether or not to escape the query (it's mentioned <a href="http://codeigniter.com/user_guide/database/active_record.html#select">here</a>) for those that were wondering.
</p>]]></description>
      <pubDate>Thu, 28 Jan 2010 13:39:45 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Harun Yayli's Blog: oci_bind_by_name maxlength is not so optional]]></title>
      <guid>http://www.phpdeveloper.org/news/10156</guid>
      <link>http://www.phpdeveloper.org/news/10156</link>
      <description><![CDATA[<p>
<i>Harun Yayli</i> <a href="http://livebookmark.net/journal/2008/05/06/oci_bind_by_name-maxlength-is-not-so-optional/">came across</a> a slight problem in his development using the oci_bind_by_name function for one of his queries:
</p>
<blockquote>
If you think that the maxlength parameter in the documentation of oci_bind_by_name is optional, see this example and think again.
</blockquote>
<p>
His sample code gave him a "can bind a LONG value only for insert into a LONG column..." error from his Oracle database. His fix was to add that length parameter (his max column length) and all was well. One of his comments (from <i>cj</i>) helps to explain things a bit more:
</p>
<blockquote>
It makes senses that a length would be required because when the oci_bind_by_name() call is made, there is no data in $$key (a.k.a. $a, $b or $c). Without a length passed, PHP tells the DB to expect a single byte string.
</blockquote>]]></description>
      <pubDate>Fri, 09 May 2008 13:45:44 -0500</pubDate>
    </item>
  </channel>
</rss>
