<?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, 17 May 2012 03:41:10 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Gonzalo Ayuso's Blog: Building a simple SQL wrapper with PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/17953</guid>
      <link>http://www.phpdeveloper.org/news/17953</link>
      <description><![CDATA[<p>
In <a href="http://gonzalo123.wordpress.com/2012/05/14/building-a-simple-sql-wrapper-with-php/">this new post</a> to his blog <i>Gonzalo Ayuso</i> has shared a simple SQL wrapper that he uses to work with his databases. It takes in an injection of the database connection component (a href="http://php.net/pdo">PDO</a>) and provides functionality for inserts, updates, etc. with transaction support.
</p>
<blockquote>
If we don't use an ORM within our projects we need to write SQL statements by hand. I don't mind to write SQL. It's simple and descriptive but sometimes we like to use helpers to avoid write the same code again and again. Today we are going to create a simple library to help use to write simple SQL queries.
</blockquote>
<p>
It's a <a href="https://github.com/gonzalo123/sqlWrapper">lightweight library</a> that'd be good for basic uses, but when you start getting into something a bit more complex, something like <a href="http://www.doctrine-project.org/">Doctrine2</a> or <a href="http://www.propelorm.org/">Propel</a> might be a better solution (or whatever your framework of choice has built in).
</p>]]></description>
      <pubDate>Mon, 14 May 2012 10:17:10 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[PHPMaster.com: Using an Access Database with PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/17927</guid>
      <link>http://www.phpdeveloper.org/news/17927</link>
      <description><![CDATA[<p>
On the PHPMaster.com site there's a new tutorial (from <i>David Francis</i>) about <a href="http://phpmaster.com/using-an-access-database-with-php/">connecting to a database</a> (a basic introduction using <a href="http://php.net/pdo">PDO</a>) and doing some of the common operations with the connection.
</p>
<blockquote>
Wouldn't it have been better for them to able to maintain their database where ever they were? Of course, but how? Simple - put it online.  [...] In this article I'll focus on the essential elements of PHP you'll need to use an existing Access database online. One other item that's standard with a Windows installation is the availability of ODBC drivers. These are essential for the use of Access from PHP.
</blockquote>
<p>
He includes a sample database structure (with "product", "product_category" and "category" tables)  and includes some sample code showing how to connect to the remote database and perform some basic actions - select, update, insert and delete
</p>]]></description>
      <pubDate>Tue, 08 May 2012 14:57:38 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[PHPMaster.com: Building a Domain Model - Integrating Data Mappers]]></title>
      <guid>http://www.phpdeveloper.org/news/17691</guid>
      <link>http://www.phpdeveloper.org/news/17691</link>
      <description><![CDATA[<p>
In <a href="http://phpdeveloper.org/news/17591">this previous post</a> PHPMaster.com introduced you to the concept of "domain models", structures defining how data should be formatted for consistency. In <a href="http://phpmaster.com/integrating-the-data-mappers/">this second part</a> of the series, <i>Alejandro</i> show show to integrate them with a data access layer (DAL) to make them easier to work with.
</p>
<blockquote>
The phrase may sound like an cheap clich&eacute;, I know, but I'm not particularly interested in reinventing the wheel each time I tackle a software problem (unless I need a nicer and faster wheel, of course). In this case, the situation does warrant some additional effort considering we'll be trying to connect a batch of mapping classes to a blog's domain model. Given the magnitude of the endeavor, the idea is to set up from scratch a basic Data Access Layer (DAL) so that domain objects can easily be persisted in a MySQL database, and in turn, retrieved on request through some generic finders.
</blockquote>
<p>
He includes all the code you'll need to create a (namespaced) database adapter (PDO), the mapping layer to tie the domain models together and using it all in a practical "blog" example with posts, comments and users.
</p>]]></description>
      <pubDate>Mon, 19 Mar 2012 11:27:26 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[NetTuts.com: PDO vs. MySQLi: Which Should You Use?]]></title>
      <guid>http://www.phpdeveloper.org/news/17572</guid>
      <link>http://www.phpdeveloper.org/news/17572</link>
      <description><![CDATA[<p>
On the NetTuts.com site today there's <a href="http://net.tutsplus.com/tutorials/php/pdo-vs-mysqli-which-should-you-use/">a quick tutorial</a> comparing two of the main database access methods available to PHP developers - PDO and MySQLi - based on performance and features they each have.
</p>
<blockquote>
When accessing a database in PHP, we have two choices: <a href="http://www.php.net/manual/en/book.mysqli.php">MySQLi</a> and <a href="http://www.php.net/manual/en/book.mysqli.php">PDO</a>. So what should you know before choosing one? The differences, database support, stability, and performance concerns will be outlined in this article.
</blockquote>
<p>
The article starts with a summary of what each of the tools offers as far as features, things like the API to work with the interface, difficulty of making connections, use of prepared statements and performance. This is followed by a few code examples showing the same actions on each side:
</p>
<ul>
<li>Making a new connection
<li>Databases supported (PDO has drivers)
<li>Named parameters
<li>Object mapping
<li>Security
<li>Performance
</ul>
<blockquote>
Ultimately, PDO wins this battle with ease. With support for twelve different database drivers (eighteen different databases!) and named parameters, we can ignore the small performance loss, and get used to its API. From a security standpoint, both of them are safe as long as the developer uses them the way they are supposed to be used (read: prepared statements).
</blockquote>]]></description>
      <pubDate>Wed, 22 Feb 2012 11:58:59 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Gonzalo Ayuso's Blog: How to protect from SQL Injection with PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/17514</guid>
      <link>http://www.phpdeveloper.org/news/17514</link>
      <description><![CDATA[<p>
In a recent post to his blog, <i>Gonzalo Ayuso</i> shares a few tips on <a href="http://gonzalo123.wordpress.com/2012/02/06/how-to-protect-from-sql-injection-with-php/">preventing SQL injection</a> attacks on your applications.
</p>
<blockquote>
Security is a part of our work as developers. We need to ensure our applications against malicious attacks. SQL Injection is one of the most common possible attacks. Basically SQL Injection is one kind of attack that happens when someone injects SQL statements in our application. You can find a lot of info about SQL Injection attack. Basically you need to follow the security golden rule: "Filter input, Escape output".
</blockquote>
<p>
He advocates the use of the PDO abstraction layer to filter out a lot of the issues. Using its prepared statements, you can easily strip out things that just adding slashes to user input wouldn't prevent. He also includes a reminder about database permissions - allowing only certain users the ability to, for example, delete can help provide one more level of security (in other words, don't use a "super user" in production).
</p>]]></description>
      <pubDate>Wed, 08 Feb 2012 08:07:05 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[PHPMaster.com: The Liskov Substitution Principle]]></title>
      <guid>http://www.phpdeveloper.org/news/17442</guid>
      <link>http://www.phpdeveloper.org/news/17442</link>
      <description><![CDATA[<p>
On PHPMaster.com today there's a new post from <i>Alejandro Gervasio</i> about a part of the <a href="http://en.wikipedia.org/wiki/SOLID_(object-oriented_design)">SOLID</a> development methods - the <a href="http://phpmaster.com/liskov-substitution-principle/">Liskov Substitution Principle</a> - the idea that objects should be replaceable with instances of their subtypes without a change to the architecture of the application.
</p>
<blockquote>
Even when the formal definition of the LSP makes eyes roll back (including mine), at its core it boils down to avoiding brittlely-defined class hierarchies where the descendants expose a behavior radically different from the base abstractions consuming the same contract.
</blockquote>
<p>
He includes an example with a "deleted scene" from the Matrix depicting an attempted override of the PDO functionality with a subclass that, unfortunately, does not match the original's structure/method definitions. The problem was in the difference between the method signature for the "query" method. It help resolve situations like this he recommends creating a "contract" in the form of an interface your code can implement, forcing it to conform to a certain structure. Using this, he provides a rewrite of the "PdoAdapter" class to match the original signature 
</p>]]></description>
      <pubDate>Tue, 24 Jan 2012 13:40:35 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Ariz Jacinto's Blog: Compiling PHP with MSSQL Server's Native ODBC Driver for Linux as a PDO Driver]]></title>
      <guid>http://www.phpdeveloper.org/news/17372</guid>
      <link>http://www.phpdeveloper.org/news/17372</link>
      <description><![CDATA[<p>
<i>Ariz Jacinto</i> has written up <a href="http://blog.acjacinto.com/2011/11/compiling-php-with-mssql-servers-native.html">a new post</a> with the commands you'll need to get PHP up and runnign with MSSQL Server's native ODBC driver working on linux (accessible through PDO).
</p>
<blockquote>
Last month, MS announced the preview release of <a href="http://blogs.msdn.com/b/brian_swan/archive/2011/10/13/microsoft-announces-sql-server-odbc-driver-for-linux.aspx">SQL Server ODBC Driver for Linux</a>, a 64-bit binary driver for Red Hat Enterprise Linux 5. This is good news for companies using heterogenous platforms e.g. LAMP stack running a PHP application that connects to both MySQL and MSSQL Server. Meaning, these companies no longer have to use third-party drivers such as <a href="http://www.freetds.org/">FreeTDS</a> that MS doesn't support. Then a few days ago, MS <a href="http://www.microsoft.com/download/en/details.aspx?id=28160">released version 1 of the driver</a>. I immediately downloaded the driver and recompiled PHP with it as a PDO  (PHP Data Object) ODBC driver.
</blockquote>
<p>
His process has five steps to it, including one for making a test script (code included) and another with a few gotchas/performance considerations to keep an eye out for when using the driver.
</p>]]></description>
      <pubDate>Tue, 10 Jan 2012 12:34:26 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[PHPMaster.com: Writing Custom Session Handlers]]></title>
      <guid>http://www.phpdeveloper.org/news/17319</guid>
      <link>http://www.phpdeveloper.org/news/17319</link>
      <description><![CDATA[<p>
On PHPMaster.com today there's a new post showing you how to <a href="http://phpmaster.com/writing-custom-session-handlers/">write custom session handlers</a> - in their case, a database-based option that can span across multiple servers/services.
</p>
<blockquote>
Sessions are a tool which helps the web programmer overcome the stateless nature of the internet. You can use them to build shopping carts, monitor visits to a website, and even track how a user navigates through your application. PHP's default session handling behavior can provide all you need in most cases, but there may be times when you want to expand the functionality and store session data differently. This article will show you how the default functionality works and then goes on to show you how override it to provide a custom solution.
</blockquote>
<p>
They introduce how sessions are stored normally (based on the save path) and what the serialized contents of it would look like. They show you how to take this, normally stored on the local file system, and change it to be written to a "session" table in a MySQL database (via <a href="http://php.net/pdo">PDO</a>). It includes reading, writing, updating and some garbage collection to clean out old values from the table.
</p>]]></description>
      <pubDate>Thu, 29 Dec 2011 09:41:25 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Lorna Mitchell's Blog: Handling SQL Errors in PDO]]></title>
      <guid>http://www.phpdeveloper.org/news/17134</guid>
      <link>http://www.phpdeveloper.org/news/17134</link>
      <description><![CDATA[<p>
<i>Lorna Mitchell</i> has a quick new post showing one way to <a href="http://www.lornajane.net/posts/2011/handling-sql-errors-in-pdo">handle SQL errors in PDO</a> that could pop up because of badly written/generated SQL statements.
</p>
<blockquote>
I love <a href="http://php.net/pdo">PHP's PDO (PHP Data Objects)</a> extension; it gives a consistent, object-oriented interface to handling all kinds of relational database backends. One thing that annoys me is that the MySQL driver for PDO defaults to a silent error mode which can make SQL errors tricky to spot!
</blockquote>
<p>
In her two code snippets she shows a failing PDO request (that fails silently) and a method for catching this issue - checking the result of the "<a href="http://us2.php.net/manual/en/pdo.errorcode.php">errorCode</a>" method to see if it equals "0" (zero). If there were errors, you can use the "<a href="http://us2.php.net/manual/en/pdo.errorinfo.php">errorInfo</a>" function to get to them. This will return the SQL error code, the driver-specific error code and a driver-specific error message.
</p>]]></description>
      <pubDate>Wed, 16 Nov 2011 09:43:34 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[DZone.com: Hardening PHP: SQL injection - Complete walkthrough]]></title>
      <guid>http://www.phpdeveloper.org/news/16711</guid>
      <link>http://www.phpdeveloper.org/news/16711</link>
      <description><![CDATA[<p>
On DZone.com today there's a new post from <i>Krzysztof Kotowicz</i> sharing a presentation of his about <a href="http://php.dzone.com/news/hardening-php-sql-injection">protecting your application from SQL injection</a>.
</p>
<blockquote>
The materials teach how to use prepared statements, how to escape and write secure stored procedures. Many PHP projects are covered - <a href="http://php.net/manual/en/book.pdo.php">PDO</a>, <a href="http://propel.phpdb.org/trac/">Propel</a>, <a href="http://www.doctrine-project.org/">Doctrine</a>, <a href="http://framework.zend.com/">Zend Framework</a> and <a href="http://pear.php.net/MDB2/">MDB2</a>. Multiple gotchas and caveats are included. I discuss why escaping is usually the wrong choice, which practices to avoid or follow and how stored procedures sometimes offer no protection at all.
</blockquote>
<p>
The presentation (as <a href="http://www.slideshare.net/kkotowicz/sql-injection-complete-walktrough-not-only-for-php-developers">posted to Slideshare</a>) starts with some of the basics - what SQL injection is and an example of how it could be used to bypass security. He covers how to use prepared statements in each of the technologies (with code snippets), methods for escaping data and how to create stored procedures that are protected from the same threats.
</p>]]></description>
      <pubDate>Fri, 12 Aug 2011 09:20:13 -0500</pubDate>
    </item>
  </channel>
</rss>

