<?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>Fri, 24 May 2013 15:35:16 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[BinaryTides.com: PHP Socket programming tutorial]]></title>
      <guid>http://www.phpdeveloper.org/news/18267</guid>
      <link>http://www.phpdeveloper.org/news/18267</link>
      <description><![CDATA[<p>
On the BinaryTides.com site there's a recent tutorial showing you how to <a href="http://www.binarytides.com/blog/php-socket-programming-tutorial-for-beginners/">effectively use sockets</a> in your PHP applications, complete with incoming and outgoing examples.
</p>
<blockquote>
This is a quick guide/tutorial to learning socket programming in php. Socket programming php is very similar to C. Most functions are similar in names, parameters and output. However unlike C, socket programs written in php would run the same way on any os that has php installed. So the code does not need any platform specific changes (mostly).
</blockquote>
<p>
They start with the basics - creating a socket, connecting to a server and sending out information over the connection. They also include the code examples showing how to pull in data from the socket. Their example socket is set up to be a simplistic web server, returning data according to the standards for a normal GET request. They make a mini-server out of it, getting to to accept requests on a bound socket.
</p>]]></description>
      <pubDate>Tue, 24 Jul 2012 12:14:37 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Davey Shafik's Blog: The Closure Puzzle]]></title>
      <guid>http://www.phpdeveloper.org/news/17397</guid>
      <link>http://www.phpdeveloper.org/news/17397</link>
      <description><![CDATA[<p>
<i>Davey Shafik</i> has <a href="http://daveyshafik.com/archives/32789-the-closure-puzzle.html">posted about an interesting find with closures</a> in PHP revolving around an update to add "$this" access inside the closure.
</p>
<blockquote>
However, it didn't stop there; there was also the addition of Closure::bind() and Closure->bindTo(). These methods are identical except one is a static method into which the closure is passed, the second an instance method on the closure itself. These methods both take two arguments (on top of the closure for the static version): $newthis and $newscope. What this means is that unlike the regular object model the concept of $this and lexical scope (what is in scope for the function with regards to private/protected methods inside objects) are completely separated.
</blockquote>
<p>
He also mentions that you can change the "$this" to a different object (complex) or swapping out the object the closure is bound to while keeping "$this" the same (simpler). He mentions that it could be useful for unit testing but can have its drawbacks. He's <a href="https://gist.github.com/1607647">included code</a> to illustrate 
 the breakage it can cause in the PHP OOP model (with an explanation).
</p>]]></description>
      <pubDate>Mon, 16 Jan 2012 09:52:38 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Till Klampaeckel's Blog: Zend Framework: Writing an IN-Clause with Zend_Db]]></title>
      <guid>http://www.phpdeveloper.org/news/15612</guid>
      <link>http://www.phpdeveloper.org/news/15612</link>
      <description><![CDATA[<p>
In <a href="http://till.klampaeckel.de/blog/archives/129-Zend-Framework-Writing-an-IN-Clause-with-Zend_Db.html">a new post</a> to his blog <i>Till Klampaeckel</i> looks at something the Zend Framework's Zend_Db component dosen't seem to support - an "IN" on a fetchAll - and how he worked around it.
</p>
<blockquote>
The IN-clause is only supported when I wrap my statement with Zend_Db_Select, which is something I rarely do. Part of the reason is that I still don't feel comfortable writing my SQL in a DSL which doesn't really do anything besides wrapping a string into an object and IMHO it doesn't add to readability either. And the other reason is that I don't plan to run this import against any other database than MySQL. Which is why I don't see the need for abstraction either.
</blockquote>
<p>
He shows some failing code where the IN isn't populated correctly when an array is passed in and the warnings that come with it. He solution's pretty simple, though - rewrite the query string before sending it with the correct number of bind locations ("?") for the number of parameters. In the comments, other approaches are suggested including using a simple select() call or tricking the bindings with a special kind of array. 
</p>]]></description>
      <pubDate>Tue, 21 Dec 2010 13:16:07 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Gonzalo Ayuso's Blog: Performance analysis using bind parameters with PDO and PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/15235</guid>
      <link>http://www.phpdeveloper.org/news/15235</link>
      <description><![CDATA[<p>
<i>Gonzalo Ayuso</i> has <a href="http://gonzalo123.wordpress.com/2010/10/05/performance-analysis-using-bind-parameters-with-pdo-and-php/">posted the results</a> of some performance testing he did with bind parameters in a PDO-based request for his application.
</p>
<blockquote>
Some months ago a work mate asked me for the differences between using bind variables versus executing the SQL statement directly as a string throughout a PDO connection. Basically the work-flow of almost all database drivers is the same: Prepare statement, execute and fetch results. [...] What's the best one? Both method work properly. The difference is how databases manage the operation internally.
</blockquote>
<p>
He gives two code examples, one with the bind parameters and one without, and the benchmark code he used to generate his statistics. It uses a PDO connection to execute several statements in a row both with bind parameters and without, measuring the time (with <a href="http://php.net/microtime">microtime</a>) and outputting the results. His results show that while the simple update is faster, the bind parameter method has the added benefit of reusability for multiple queries.
</p>]]></description>
      <pubDate>Wed, 06 Oct 2010 08:57:02 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Brian Swan's Blog: What's the Right Way to Prevent SQL Injection in PHP Scripts?]]></title>
      <guid>http://www.phpdeveloper.org/news/14140</guid>
      <link>http://www.phpdeveloper.org/news/14140</link>
      <description><![CDATA[<p>
<i>Brian Swan</i> has a new post today looking at one way you can protect your web application from potential attack - <a href="http://blogs.msdn.com/brian_swan/archive/2010/03/04/What_2700_s-the-right-way-to-avoid-SQL-injection-in-PHP-scripts_3F00_.aspx">preventing SQL injection</a> by filtering input.
</p>
<blockquote>
How to prevent SQL injection in PHP scripts is probably a topic that doesn't need anything more written about it. [...] However, it is important to have fresh information for new Web developers and I don't necessarily agree with some of the most common suggestions for preventing SQL injection. [...] So, this will be yet another post about preventing SQL injection, but I will offer my 2 cents about what I think is the right way to prevent it.
</blockquote>
<p>
He explains SQL injections for those that are unsure on the concept with a basic form example and what he thinks is a better way to prevent it than just trying to escape the SQL - bound parameters. These allow you to both filter and protect your application from any would-be attacks that might come your way. He is, of course, using SQL Server so the parameter binding is included in the database functionality. Other databases might have to use something like <a href="http://php.net/pdo">PDO</a> to accomplish the same kind of thing.
</p>]]></description>
      <pubDate>Fri, 05 Mar 2010 13:47:43 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Davey Shafik's Blog: Debugging PDO Prepared Statements]]></title>
      <guid>http://www.phpdeveloper.org/news/12543</guid>
      <link>http://www.phpdeveloper.org/news/12543</link>
      <description><![CDATA[<p>
In <a href="http://daveyshafik.com/archives/605-debugging-pdo-prepared-statements.html">a recent post</a> to his blog, <i>Davey Shafik</i> looks at solving something that has "always bugged him about using prepared statements" - getting the actual query it used back out.
</p>
<blockquote>
Today, a friend asking me if it was possible to get a prepared statement back from PDO with the values placeholders replaced, finally caught me in a moment where I could do something about it. I wrote a thin PDO wrapper class that will [imperfectly, I'm sure] return the completed query.
</blockquote>
<p>
His class (complete code included in <a href="http://daveyshafik.com/archives/605-debugging-pdo-prepared-statements.html">the post</a>) includes a getSQL() method that hands you back the results of your bound parameter query as a string. A few examples of its use are also included.
</p>]]></description>
      <pubDate>Wed, 20 May 2009 09:35:01 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[SitePoint PHP Blog: The state of functional programming in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/9253</guid>
      <link>http://www.phpdeveloper.org/news/9253</link>
      <description><![CDATA[<p>
On the SitePoint PHP Blog today, <i>Troels Knak-Nielsen</i> has <a href="http://www.sitepoint.com/blogs/2007/12/15/the-state-of-functional-programming-in-php/">written up a post</a> concerning the current state of <a href="http://lambda-the-ultimate.org/node/2539">functional programming</a> in PHP.
</p>
<blockquote>
With the rise of Javascript, and languages like Python and Ruby, <a href="http://lambda-the-ultimate.org/node/2539">functional programming</a> is becoming more mainstream. Even Java seems to be <a href="http://rickyclarkson.blogspot.com/2007/11/java-7-example-writing-your-own-foreach.html">getting closures</a> in the next version, so does this leave PHP lacking behind or is there an unrealized potential hidden within?
</blockquote>
<p>
He looks at a few different aspects of functional programming and sees how well PHP fits into them (like dynamic dispatch, binding a variable to a function and an implementation of <a href="http://en.wikipedia.org/wiki/Currying">currying</a> for a function). This last option is the only "true" functional feature that PHP can realistically handle. 
</p>]]></description>
      <pubDate>Mon, 17 Dec 2007 10:28:00 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Internet Super Hero Blog: PHP: mysqli_stmt_get_result()]]></title>
      <guid>http://www.phpdeveloper.org/news/8513</guid>
      <link>http://www.phpdeveloper.org/news/8513</link>
      <description><![CDATA[<p>
Frustrated with the lack of something simple (like mysql_fetch_assoc) in the new mysqli extension, <a href="http://blog.ulf-wendel.de/?p=156">this new function</a> was created an posted about on the Internet Super Hero blog - mysqli_stmt_get_results.
</p>
<blockquote>
By help of the new function, you can create a <a href="http://www.php.net/manual/en/ref.mysqli.php">mysqli_result object</a> from a statement that returns data (SELECT and other - <a href="http://dev.mysql.com/doc/refman/5.1/en/c-api-prepared-statements.html">version dependent!</a>). Then you can use the mysqli_result object to process the returned data: fetch results, access meta data - all you can also do using a mysqli_result object returned by <a href="http://php.net/mysqli_query">mysqli_query()</a>.
</blockquote>
<p>
Included in <a href="http://blog.ulf-wendel.de/?p=156">the post</a> are a few code examples showing the simplicity of the function and how it can still be used with the standard mysql_* functions to grab the results. 
</p>]]></description>
      <pubDate>Wed, 22 Aug 2007 13:48:00 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Maggie Nelson's Blog: How to (and how not to) pass an array from PHP to the database]]></title>
      <guid>http://www.phpdeveloper.org/news/8250</guid>
      <link>http://www.phpdeveloper.org/news/8250</link>
      <description><![CDATA[<p>
In a <a href="http://www.objectivelyoriented.com/2007/07/how_to_and_how_not_to_pass_an_1.html">new post</a> today, <i>Maggie Nelson</i> starts with the wrong way to do something - passing an array from PHP to a database - and works backward to make it all right.
</p>
<blockquote>
It would be really useful to have an easy way to pass arrays as bound parameters to queries or procedures from PHP. This would be especially useful if you're letting Oracle handle most of your data manipulating (as you should).
</blockquote>
<p>
She includes an example of how she's like it to work. Sadly, it doesn't but there are some ways that a developer could get close. Here's her process:
</p>
<ul>
<li>No queries in loops, please!
<li>In the ideal world...
<li>Put all your DML in stored procedures.
<li>str2tbl
<li>The list_pkg package
<li>list_pkg in your procedure
<li>list_pkg in your PHP
<li>Leveraging list_pkg
</ul>
<p>
The list_pkg is based around <a href="http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:110612348061">this article</a> from AskTom.
</p>]]></description>
      <pubDate>Mon, 16 Jul 2007 11:13:00 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Paul Jones' Blog: New PDO Behavior In PHP 5.2.1]]></title>
      <guid>http://www.phpdeveloper.org/news/7358</guid>
      <link>http://www.phpdeveloper.org/news/7358</link>
      <description><![CDATA[<p>http://www.phpdeveloper.org/form/view/type/addnews
PHPDeveloper.org: PHP News, Views, and Community
In a <a href="http://paul-m-jones.com/blog/?p=243">new post</a> <i>Paul Jones</i> points out some of the new behaviors that the extension is showing in the latest of the PHP 5 seres (version 5.2).
</p>
<p>
He starts with a code example that would work with a previous version of PHP/PDO that would allow for the binding of a single value to multiple places in the SQL statement. But:
</p>
<blockquote>
Sadly, this is no longer the case in PHP 5.2.1. For valid reasons of security and stability in memory handling, as noted to me by Wez Furlong, the above behavior is no longer supported. That is, you cannot bind a single parameter or value to multiple identical placeholders in a statement. If you try it, PDO will throw an exception or raise an error, and will not execute the query. In short, you now need to match exactly the number of bound parameters or values with the number of placeholders.
</blockquote>
<p>
Unfortunately, this is used quite often in <i>Paul</i>'s <a href="http://solarphp.com/">Solar</a> framework, so an update to the Solar_Sql_Adapter::query() method has had to been made to allow for the binding of multiple items automatically. It works by incrementing the bind location (like ":foo") with numbers at the end - simple and effective - and you can still pass an array to it and have it automagically work.
</p>]]></description>
      <pubDate>Wed, 28 Feb 2007 08:29:00 -0600</pubDate>
    </item>
  </channel>
</rss>
