<?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>Wed, 22 May 2013 15:31:21 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Duckout Blog: Do Funny Stuff with the Google Charts API and PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/19366</guid>
      <link>http://www.phpdeveloper.org/news/19366</link>
      <description><![CDATA[<p>
In <a href="http://www.duckout.de/programming/do-funny-stuff-with-the-google-charts-api-and-php/">this recent post</a> to the Duckout blog, they show you how to hook your PHP-based (and database driven) application into the Google Charting API for chart/graph generation.
</p>
<blockquote>
I think, whenever we see a chart in a magazine, in books or applications our brain say's to us Yeepie!!! Don't read these stupid texts or tables! Just look at the green or yellow line and hope that they are above the other lines or hope that your opinion is the biggest part of the pie¯. This saves us a lot of work and in my opinion we should concentrate on drawing beautiful colorized pie charts, instead of writing long boring articles. But the question is: ¯How do I draw these beautiful colorized pie charts? The simple answer is: you don't have to, because google will draw them for you and you just have to tell them what to draw via the google charts api.
</blockquote>
<p>
The <a href="https://github.com/Gamma32/breakfast">sample application</a> is a "breakfast rating" tool that logs the results to a MySQL database via PDO calls. The results are then extracted and formated as JSON to be compatible with the Google Charts API data handling. Some sample Javascript is included showing how to call the Charts API with your data and get back a simple line graphing of the data from the database. You can see the application in action <a href="http://breakfast.cloudcontrolled.com/">here</a> for reference.
</p>]]></description>
      <pubDate>Tue, 26 Mar 2013 11:40:44 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Michelangelo van Dam: Look mama, no databases]]></title>
      <guid>http://www.phpdeveloper.org/news/19325</guid>
      <link>http://www.phpdeveloper.org/news/19325</link>
      <description><![CDATA[<p>
In his most recent post <i>Michelangelo van Dam</i> talks about <a href="http://www.dragonbe.com/2013/03/look-mama-no-databases.html">unit testing and databases</a> and how, to effectively test what should be tested (the code, not "the ability to fetch data") you need to correctly mock your database objects.
</p>
<blockquote>
When I state "as is", I truly mean the way it's being used in production. So the database call collects real data on which business logic is applied. You can see this is not a healthy situation, especially when you also have services that apply business logic on data and store it back into the database. In "<a href="https://leanpub.com/grumpy-phpunit?ref=dragonbe>The Grumpy Programmer's PHPUnit Cookbook</a>", author <a href="https://twitter.com/grmpyprogrammer">Chris Hartjes</a> wrote this one sentence that says it all: "Unit test suites are meant to be testing code, not the ability of a database server to return results". And he's right, you shouldn't use database connections when your testing business rules and functional logic.
</blockquote>
<p>
He goes on to show a few code examples that show a pre-mocked state of testing where the Product information is pulled directly from a PDO connection. The more correct version mocks out this object, though, and overrides the "execute" and "fetchAll" methods to return mocked results. 
</p>]]></description>
      <pubDate>Mon, 18 Mar 2013 10:11:46 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[PHPMaster.com: Avoid the Original MySQL Extension, Part 2]]></title>
      <guid>http://www.phpdeveloper.org/news/19235</guid>
      <link>http://www.phpdeveloper.org/news/19235</link>
      <description><![CDATA[<p>
PHPMaster.com has posted the <a href="http://phpmaster.com/avoid-the-original-mysql-extension-2/">second part</a> of their "avoid the original MySQL extension" tutorial series (part one is <a href="http://phpmaster.com/avoid-the-original-mysql-extension-1/">here</a>). In this new part, they share more about another alternative - the PDO extension.
</p>
<blockquote>
The PDO extension supports twelve drivers, enabling it to connect to a variety of relational databases without the developer having to learn a number of different APIs. It does this by abstracting the database interaction calls behind a common interface, enabling the developer to utilize a consistent interface for different databases. This of course gives it a major advantage over both the MySQL and MySQLi extensions who are limited to only one database.
</blockquote>
<p>
Included in the post are examples of some of the basics - connecting, executing queries, getting the results - as well as more compelx things like binding parameters and transaction support. There's also a bit about changing the default behavior of the PDO object through config options. He finishes off the article talking some about some of the issues that could come from using an abstraction layer like this and the need to still write good, compatible SQL depending on the database.
</p>]]></description>
      <pubDate>Mon, 25 Feb 2013 13:40:09 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Gonzalo Ayuso: Handling several PDO Database connections in Symfony2 through the DIC in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/19007</guid>
      <link>http://www.phpdeveloper.org/news/19007</link>
      <description><![CDATA[<p>
<i>Gonzalo Ayuso</i> has <a href="http://gonzalo123.com/2013/01/07/handling-several-pdo-database-connections-in-symfony2-through-the-dependency-injection-container-with-php/">written up a new post</a> about a handling method he's worked up for working with multiple PDO instances (database connections) through the Symfony2 dependency injection container using custom YML definitions and a simple "Db" class.
</p>
<blockquote>
I'm not a big fan of ORMs, especially in PHP world when all dies at the end of each request. Plain SQL is easy to understand and very powerful. Anyway in PHP we have Doctrine. Doctrine is a amazing project, probably (with permission of Symfony2) the most advanced PHP project, but I normally prefer to work with SQL instead of Doctrine. [...] Due to my daily work I need to connect to different databases (not only one) in my applications.
</blockquote>
<p>
He shows the normal setup using the "parameters.yml" file to define the multiple database connections but notes that this isn't the most ideal solution. Instead, he walks you through the steps to create the "databases.yml" configuration file and a simple "Db" class that acts as an interface to pull the PDO objects from the container. You can then just call the "get" method on the container to extract the fully configured PDO object, ready for use.
</p>]]></description>
      <pubDate>Tue, 08 Jan 2013 11:52:40 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Chris Jones: How (and when) to move users to mysqli and PDO_MYSQL?]]></title>
      <guid>http://www.phpdeveloper.org/news/18803</guid>
      <link>http://www.phpdeveloper.org/news/18803</link>
      <description><![CDATA[<p>
Related to a recent discussion on the <a href="http://news.php.net/php.internals">php.internals</a> mailing list, <i>Chris Jones</i> has <a href="https://blogs.oracle.com/opal/entry/how_and_when_to_move">posted about moving away from the MySQL extension</a> in favor of the MySQLi functionality and the effort bubbling up to make the old functionality <a href="https://wiki.php.net/rfc/mysql_deprecation">deprecated</a>.
</p>
<blockquote>
An important discussion on the PHP "internals" development mailing list is taking place. It's one that you should take some note of. It concerns the next step in transitioning PHP applications away from the very old mysql extension and towards adopting the much better mysqli extension or PDO_MYSQL driver for PDO. This would allow the mysql extension to, at some as-yet undetermined time in the future, be removed.
</blockquote>
<p>
He links to a <a href="https://wiki.php.net/rfc/mysql_deprecation">RFC</a> that's been posted to help promote and push this idea forward with mentions of the "carrot" and "stick" methods for pushing users towards <a href="http://php.net/mysqli">mysqli</a>.
</p>
<blockquote>
As always, there is a lot of guesswork going on as to what MySQL APIs are in current use by PHP applications, how those applications are deployed, and what their upgrade cycle is. [...] I want to repeat that no time frame for the eventual removal of the mysql extension is set. I expect it to be some years away.
</blockquote>]]></description>
      <pubDate>Mon, 26 Nov 2012 11:04:25 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[PHPEasy.co.uk: Object Orientation Basics part 4 - Implementing CRUD methods]]></title>
      <guid>http://www.phpdeveloper.org/news/18328</guid>
      <link>http://www.phpdeveloper.org/news/18328</link>
      <description><![CDATA[<p>
PHPEasy.co.uk continues their series looking at some of the basics of Object-Oriented Programming (OOP) in PHP with <A href="http://phpeasy.co.uk/tutorial-object-orientation-basics-part-4-implementing-crud-methods/">part four</a> showing how to implement CRUD methods (Create/Read/Update/Delete) on a database connection.
</p>
<blockquote>
In the last tutorial in this beginners series we discussed using PDO to connect to a MySQL database. Following on from that tutorial we are going to improve the Guitar class we made by adding some basic CRUD methods so that our class can interact with our database using PDO.
</blockquote>
<p>
He brings back the same class structure and shows how to take a "Guitar" object, create a connection via a "conn()" method and use the getters/setters to assign values for saving, selecting, deleting and updating the database's records.
</p>]]></description>
      <pubDate>Tue, 07 Aug 2012 12:23:36 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[NetTuts.com: PHP Database Access: Are You Doing It Correctly?]]></title>
      <guid>http://www.phpdeveloper.org/news/18044</guid>
      <link>http://www.phpdeveloper.org/news/18044</link>
      <description><![CDATA[<p>
In <a href="http://net.tutsplus.com/tutorials/php/php-database-access-are-you-doing-it-correctly/">this new tutorial</a> on NetTuts.com, they talk about one of the more fundamental connection types you can do in PHP - database connections. They want to be sure you're "doing it correctly" via PHP's PDO API.
</p>
<blockquote>
We've covered PHP's PDO API a <a href="http://net.tutsplus.com/tutorials/php/why-you-should-be-using-phps-pdo-for-database-access/">couple</a> of <a href="http://net.tutsplus.com/tutorials/php/pdo-vs-mysqli-which-should-you-use/">times</a> here on Nettuts+, but, generally, those articles focused more on the theory, and less on the application. This article will fix that! To put it plainly, if you're still using PHP's old mysql API to connect to your databases, read on!
</blockquote>
<p>
They compare the three main methods for connecting to a MySQL database - mysql, mysqli and PDO - and how a typical mysql/mysqli codebase can be refactored to use PDO. They show examples of connections, error handling, fetching data, using prepared statements and snippets of code for CRUD (Create, Read, Update, Delete) handling.
</p>
<p>
Be sure and check out the comments - there's some <a href="http://net.tutsplus.com/tutorials/php/php-database-access-are-you-doing-it-correctly/#comments">great tips there too</a>!
</p>]]></description>
      <pubDate>Mon, 04 Jun 2012 13:33:54 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Ilia Alshanetsky's Blog: Database connection fallback with PDO]]></title>
      <guid>http://www.phpdeveloper.org/news/18040</guid>
      <link>http://www.phpdeveloper.org/news/18040</link>
      <description><![CDATA[<p>
<i>Ilia Alshanetsky</i> has a new post to his blog sharing a <a href="http://ilia.ws/archives/249-Database-connection-fallback-with-PDO.html">method for fallback with PDO</a> when your database connection fails.
</p>
<blockquote>
For our database connections we PDO at work and we've extended the class with PHP to offer some other convenience functionality and wrappers. One of the things I wanted to do recently is allow the constructor of the PDO class to fail-over to our backup database connection pool in the event the primary was not available.
</blockquote>
<p>
He wanted his code to catch an exception if the object was created with a failed server host and to connect to the backup instead. PDO doesn't cooperate with this method and just destroys the object when there's a failure. His work around is in <a href="http://ilia.ws/patch/pdo.txt">this patch</a> to the PDO support in PHP to provide a new constant, PDO:: ATTR_KEEP_CLASS_CONN_FAILURE, that tells the script wether or not to destroy the PDO object when there's a problem.
</p>]]></description>
      <pubDate>Mon, 04 Jun 2012 09:50:26 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Reddit.com: Protecting against attack?]]></title>
      <guid>http://www.phpdeveloper.org/news/17978</guid>
      <link>http://www.phpdeveloper.org/news/17978</link>
      <description><![CDATA[<p>
In <a href="http://www.reddit.com/r/PHP/comments/tnval/protecting_against_attack/">this recent post</a> to Reddit.com, the question of application security is asked - the poster wants recommendations on how he should keep his app safe from would-be attackers:
</p>
<blockquote>
I can code fairly well in PHP these days, but my security isn't so hot. Is there a tutorial or plugin you guys can recommend as to how I should be protecting my php pages/inputs? I want to avoid common attacks like XSS, inputs with NULL or DROP TABLE etc?
</blockquote>
<p>
Responses <a href="http://www.reddit.com/r/PHP/comments/tnval/protecting_against_attack/">on the post</a> include recommendations related to:
</p>
<ul>
<li>Using the <a href="https://chorizo-scanner.com/">Chorizo scanner</a> to find common issues in your code
<li>Using PDO for database connections (with bound parameters)
<li>Not trusting "$_SERVER" 
<li>Data sanitization
</ul>
<p>
There's also links to <a href="http://phpmaster.com/php-security-cross-site-scripting-attacks-xss/">a few</a> <a href="https://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API">other</a> <a href="http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454">resources</a> with more details.
</p>]]></description>
      <pubDate>Fri, 18 May 2012 10:19:35 -0500</pubDate>
    </item>
    <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>
  </channel>
</rss>
