Book Review: Learning PHP Data Objects

      2 Comments on Book Review: Learning PHP Data Objects

Learning PHP Data Objects
By Dennis Popel
Review by Akash Mehta

learning_php_data_objects Learning PHP Data Objects is an introduction to the new PDO data abstraction system included in PHP5. PDO is widely accepted as an effective option for database access while keeping in line with best practices. In Learning PHP Data Objects, the author Dennis Popel examines this new system and explains how to begin using PDO in development as a replacement for typical database drivers. The book is an excellent introduction to the data abstraction layer and also provides essential insight into the inner workings of database interaction with PHP.

For many years, PHP was an emerging language, used by hobbyists in occasional development, and perceived as lacking in professionalism or standardisation. Due to its nature as a community-based language, this reputation continued for quite some time, spurred on by low-quality code and a lack of professional testing to assess developers.

However, in recent times, this has changed dramatically, especially with the advent of PHP environments for those proficient in other widely adopted languages – for example, VS.Php for Visual Studio developers. The introduction of certification programs has encouraged employers to place added emphasis on the quality of their developers, which has led to increased emphasis on best practices. Of these best practices, database abstraction is always a major concern in any significant application, and with the advent of PHP Data Objects in PHP5, an understanding of an effective solution to the problem is essential for any developer utilising database systems – and this is where Dennis Popel’s Learning PHP Data Objects comes in.

PDO is a highly efficient and powerful data abstraction interface for PHP, but as with any new technology, it comes with a reasonable learning curve. In Learning PHP Data Objects, Popel takes the tried and tested approach of learning by example, taking the reader through aspects of PHP Data Objects (PDO) by explaining them and demonstrating a sample real-world usage scenario. However, not only does he demonstrate PDO, he also identifies the key concepts of the internals of PDO and relational database management systems. By the time he is finished, the reader has a comprehensive understanding of all aspects of database interaction in PHP, an understanding which is highly useful in any real-world development scenario.

The book identifies itself as targeted at developers who need to use PDO for data abstraction. However, this is wildly incorrect. PDO is a general data interface that brings the developer close to the data while still maintaining a layer of abstraction suitable for code portability. In examining and discussing the concepts surrounding this, Popel has created a highly concise yet effectual guide to employing database systems for data storage in PHP. Any PHP developer interacting with databases who is not yet comfortable with PDO should read this book, as it provides a level of understanding that is invaluable for high-end development yet would take years to develop through other means.

The book is well structured, with each section including an introduction to the aspect of PDO being covered, an explanation, a demonstration and associated notes. Popel’s style of writing is reader-friendly and requires little thought to understand. The book assumes the reader is comfortable with PHP and understands the basics of databases, and presumes the reader will have a functioning PHP setup available if they wish to test out the code samples, which is perfectly acceptable. At the same time, Popel knows how to get to the point and provides a no-nonsense approach for expert readers. The book is full of realistic samples that accurately and effectively demonstrate effective usage of PDO, while the inclusion of screenshots associated with each sample greatly assists the reader in understanding the code.

In fact, the samples are what really make Learning PHP Data Objects stand out. Unlike most books on development topics, the samples in this book are almost identical to realistic real-world usage scenarios. Database querying can often become highly complex, as demonstrated in Chapter 7: An Advanced Example, and Popel’s samples are an excellent ongoing reference for use of PDO. Popel also demonstrates many PHP best practices, including using classes appropriate for effective code reuse. For those PHP4 developers unfamiliar with object-oriented programming (the set of concepts that includes classes), the author even includes a full appendix on the topic covering all the essentials, and this appendix is very helpful for beginner developers.

Learning PHP Data Objects is an excellently constructed, effective introduction to the world of PDO, and database interaction with PHP in general, and is a versatile reference guide. At just over 150 pages, it is concise, including all the important aspects of PHP Data Objects, as well as briefly describing related topics that the reader may wish to consider investigating for a greater understanding. The included code samples are highly effective and serve as excellent demonstrations of the use of this excellent PHP feature, while providing the reader with a ready reference for the future. In effect, it is essential for any PHP developer wishing to investigate PDO for their applications or looking to extend their skills.