<?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>Thu, 24 May 2012 18:39:27 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[ServerGrove Blog: Enforcing unique key constrains with Doctrine ODM for MongoDB & Symfony 2]]></title>
      <guid>http://www.phpdeveloper.org/news/15315</guid>
      <link>http://www.phpdeveloper.org/news/15315</link>
      <description><![CDATA[<p>
New on the ServerGrove blog today is <a href="http://blog.servergrove.com/2010/10/20/enforcing-unique-key-constrains-with-doctrine-odm-for-mongodb-symfony-2/">a quick post</a> talking about how you can enforce key constraints on a MongoDb with Doctrine in Symfony.
</p>
<blockquote>
Of course you can define unique indexes to prevent duplicate values and there are a couple of different syntax options to do so, which are clearly defined in the <a href="http://www.doctrine-project.org/projects/mongodb_odm/1.0/docs/reference/indexes/en#unique-index">official documentation</a>. But defining and creating the indexes is not enough. You must specify when you want to enforce the constrain, this is due to the fact that the PHP driver needs to tell MongoDB to throw an error when a duplicate key is found.
</blockquote>
<p>
The fix is as simple as adding a "safe" option to the "flush()" call on your database object. If you give it a value of "true", the ORM is smart enough to handle things on its own.
</p>]]></description>
      <pubDate>Thu, 21 Oct 2010 11:58:22 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Havard Eide's Blog:  SplObjectStorage]]></title>
      <guid>http://www.phpdeveloper.org/news/10662</guid>
      <link>http://www.phpdeveloper.org/news/10662</link>
      <description><![CDATA[<p>
<i>Havard Eide</i> has a <a href="http://eide.org/2008/07/21/splobjectstorage/">recent post</a> to his blog that looks at a part of the Standard PHP Library (SPL) that can be used with objects to store them for later use - SplObjectStorage.
</p>
<blockquote>
In this post I will look at SplObjectStorage: a container that allows to store objects uniquely without the need to compare them one by one.
</blockquote>
<p>
He lets the code to most of the talking, showing how to do the standard operations for a data store - adding objects (both unique and the same), updating objects in the store, checking to see if an object is already added and removing an object from storage.
</p>]]></description>
      <pubDate>Wed, 23 Jul 2008 08:47:44 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Brian Moon's Blog: in_array is quite slow]]></title>
      <guid>http://www.phpdeveloper.org/news/10357</guid>
      <link>http://www.phpdeveloper.org/news/10357</link>
      <description><![CDATA[<p>
<i>Brian Moon</i> had <a href="http://brian.moonspot.net/2008/06/05/in_array-is-quite-slow/">a problem</a> - one of his cron jobs was lasting for much longer (hours!) than it should have been. He tweaked, tested and debugged the script and finally came down to a call to <a href="http://www.php.net/in_array">in_array</a>, something he comments on as being "quite slow".
</p>
<blockquote>
See, this job is importing data from a huge XML file into MySQL.  After it is done, we want to compare the data we just added/updated to the data in the table so we can deactivate any data we did not update. [...] We then compared the two arrays by looping one array and using in_array() to check if the value was in the second array. [...] So, that was running for hours with about 400k items.  Our data did not contain the value as the key, but it could as the value was unique.  
</blockquote>
<p>
He method, replacing the in_array call that had to do a full array scan for each time through the loop with an isset/unset combo on the unique key, changed the execution time down from about 4 hours to 0.8 seconds.
</p>]]></description>
      <pubDate>Fri, 06 Jun 2008 09:36:47 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Internet Super Hero Blog: Is PDO::FETCH_UNIQUE broken by design?]]></title>
      <guid>http://www.phpdeveloper.org/news/9758</guid>
      <link>http://www.phpdeveloper.org/news/9758</link>
      <description><![CDATA[<p>
On the Internet Super Hero blog, there's a <a href="http://blog.ulf-wendel.de/?p=179">post</a> that looks at how PDO is implemented in PHP and wonders if the PDO::FETCH_UNIQUE constant is broken (as something to fix before even considering the move to PDO2).
</p>
<blockquote>
I spent quite a lot of time comparing the different behaviours of the various drivers in the hope I could find out how PDO drivers are supposed to work. The PDO documentation and the specification do not cover each and every detail. PDO really needs some love...
</blockquote>
<p>
He picks out the FETCH_UNIQUE constant as one that needs a little work and tries to track down exactly what it's doing. One issue he found was that it requires combination with other flags to make the unique part of it work correctly (like FETCH_OBJ or FETCH_COLUMN). He works through several examples, both ones that apply the unique call and others that don't, comparing the results.
</p>]]></description>
      <pubDate>Fri, 07 Mar 2008 10:25:00 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Sebastian Bergmann's Blog: Distributed Testing with PHPUnit 3.1]]></title>
      <guid>http://www.phpdeveloper.org/news/7331</guid>
      <link>http://www.phpdeveloper.org/news/7331</link>
      <description><![CDATA[<p>
In his latest post, <i>Sebastian Bergmann</i> <a href="http://sebastian-bergmann.de/archives/659-Distributed-Testing-with-PHPUnit-3.1.html">spotlights another new feature</a> of the upcoming <a href="http://www.phpunit.de/">PHPUnit</a> release - distributed testing.
</p>
<blockquote>
One of the new features in the upcoming <a href="http://www.phpunit.de/">PHPUnit 3.1</a> release is the support for distributed testing through the ability to log test result and code coverage data to a database. This way, the same test suite can be run on different platforms with the results being aggregated in the database. For this to work, however, we need a key in the database that identifies test runs from different machines as being related. A <a href="http://subversion.tigris.org/">Subversion</a> revision number is a perfect candidate for this.
</blockquote>
<p>
He <a href="http://sebastian-bergmann.de/archives/659-Distributed-Testing-with-PHPUnit-3.1.html">includes a sample script</a> that helps with the storage of the results in the database by grabbing a unique id for the machine pushing the updates in.
</p>]]></description>
      <pubDate>Thu, 22 Feb 2007 12:14:00 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[JSLabs Blog:  How to stop IE from caching AJAX requests]]></title>
      <guid>http://www.phpdeveloper.org/news/7217</guid>
      <link>http://www.phpdeveloper.org/news/7217</link>
      <description><![CDATA[<p>
If you've ever had the frustration of working with Ajax in Internet Explorer and have noticed it caching the requests/results, you might want to check out <a href="http://www.whenpenguinsattack.com/2007/02/05/how-to-stop-ie-from-caching-ajax-requests/">this new post</a> on the JSLabs blog for a helpful hint.
</p>
<blockquote>
While working on an AJAX project over the weekend, I ran into the following issue: (through a GET request), every time I tried to call a certain function, It was returning the same data (which was supposed to be different each time)
</blockquote>
<p>
First, he tried just changing the headers (via PHP's header function) to see if IE would understand the new message, but to no avail. He finally figured out that, despite whatever headers were sent or how much the content changed, what he really needed to do was to provide the script some kind of unique identifier with each request (just appended to the url) so that IE knew the request was different. His weapon of choice was a date/time value.
</p>]]></description>
      <pubDate>Mon, 05 Feb 2007 08:05:00 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[The Bakery: Checking for duplicate records (unique record)]]></title>
      <guid>http://www.phpdeveloper.org/news/7154</guid>
      <link>http://www.phpdeveloper.org/news/7154</link>
      <description><![CDATA[<p>
On The Bakery, there's a new <a href="http://bakery.cakephp.org/articles/view/189">expanded tutorial</a> (from <a href="http://wiki.cakephp.org/tutorials:duplicate_record_validation">this</a>) that talks about how to check for duplicate records in your CakePHP model.
</p>
<blockquote>
[Here's how to] validate a form field (such as a user name field), both in add and edit form and make sure that the selected user name does not already exist in the database [via a] function repeated only once (in app/app_model.php).
</blockquote>
<p>
The <a href="http://bakery.cakephp.org/articles/view/189">example model</a> they give defines an isUnique method that essentially runs an automatic check (a count() call) on the table to see if the given information exists. The example Model, View, and Controller are all given.
</p>]]></description>
      <pubDate>Tue, 23 Jan 2007 15:33:00 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[WebCheatSheet.com: Secure File Upload with PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/7122</guid>
      <link>http://www.phpdeveloper.org/news/7122</link>
      <description><![CDATA[<p>
A <a href="http://www.webcheatsheet.com/php/file_upload.php">new tutorial</a> has been posted to the WebCheatSheet.com website demonstrating a method for secure file uploads with PHP.
</p>
<blockquote>
In spite of security issues that should be addressed before enabling file uploads, the actual mechanisms to allow this are straight forward. In this tutorial we will consider how to upload files to some directory on your Web server. We will also discuss security issues concerned with the file uploading.
</blockquote>
<p>
They <a href="http://www.webcheatsheet.com/php/file_upload.php">break it up</a> into the two key parts - the HTML form and the PHP script that handles the resulting upload request. The "secure" part comes in with the validation of the upload. In this case, making sure it's a JPEG file, that its size is less than 350 KB, and that a file by that name doesn't already exist.
</p>]]></description>
      <pubDate>Thu, 18 Jan 2007 11:40:00 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Felix Geisendorfer's Blog: Handling inline links to dynamic resources]]></title>
      <guid>http://www.phpdeveloper.org/news/6664</guid>
      <link>http://www.phpdeveloper.org/news/6664</link>
      <description><![CDATA[<p>
On the ThinkingPHP Blog today, there's <a href="http://www.thinkingphp.org/2006/11/06/handling-inline-links-to-dynamic-resources/">a look at</a> how to handle inline links to dynamic resources - specifically allowing users to create links in their own content to dynamic content elsewhere on the site.
</p>
<blockquote>
I thought of something that would be both, easy to implement and easy to use. What I finally came up with is tightly coupled to my <a href="http://www.thinkingphp.org/2006/09/18/dessert-11-welcome-back-friendly-urls/">new url system</a> that I'm using, so make sure to <a href="http://www.thinkingphp.org/2006/09/18/dessert-11-welcome-back-friendly-urls/">check it out</a> in case you've missed it.
</blockquote>
<p>
The basic idea of the system is that the URL of the page (made up partly of the title) would be the unique identifier for the page. For example, "[page 12]" would be expanded out to "/pages/12:my-title". <i>Felix</i> takes this idea and runs with it, showing how to implement it in a CakePHP project inside of a Model and a Component. The sample usage code is, of course, also included in <a href="http://www.thinkingphp.org/2006/11/06/handling-inline-links-to-dynamic-resources/">the post</a>.
</p>]]></description>
      <pubDate>Wed, 08 Nov 2006 07:21:00 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Hiveminds Magazine: Using numbers in PHP function names]]></title>
      <guid>http://www.phpdeveloper.org/news/5392</guid>
      <link>http://www.phpdeveloper.org/news/5392</link>
      <description><![CDATA[<p>Content no longer valid</p>]]></description>
      <pubDate>Thu, 18 May 2006 06:14:59 -0500</pubDate>
    </item>
  </channel>
</rss>

