Monday, July 13, 2009

Beginning PHP and Oracle From Novice to Professional by W. Jason Gilmore and Bob Bryla

W. JASON GILMORE has been obsessing over all things open source for more than ten years, with a primary focus on Web development technologies. He has been extensively published in publications such as Developer.com, TechTarget, and Linux Magazine, with his writings adopted for use within the United Nations and Ford Foundation educational programs. Jason is the author of four books, including the best-selling Beginning PHP and MySQL 5
Jason spends his days running Apress’s open source program and his
evenings writing, coding, and consulting.
educating the development community. When not in front of the computer, Jason can typically be found dreaming up home-remodeling projects, playing chess, and making homemade pasta. In his effort to occasionally get away from the keyboard, he recently bought, of all things, a piano.

BOB BRYLA is an Oracle 9i and 10g Certified Professional with more than
20 years of experience in database design, database application development, training, and database administration. He is an Internet database analyst and Oracle DBA at Lands’ End, Inc., in Dodgeville, Wisconsin. He is the author of several other Oracle DBA books for both the novice and seasoned
professional.

Mahatma Gandhi once famously said, “First they ignore you, then they laugh at you, then they fight you, then you win.” Although there’s not yet any clear winner, the software industry seems to
be following a similar path. Although the open source movement began back in the 1970s due to Richard Stallman’s printer-borne frustrations in an MIT computer lab, it wasn’t until the late 1990s that the community-driven approach to software development began to make any significant waves in the business environment.
And with it came gasps of both horror and hilarity among the proprietary software elite. After all, a bunch of volunteers could hardly produce code of a quality approaching, let alone surpassing, that which is built in the hallowed cathedrals of software development, right? Such guffaws rang increasingly loudly despite numerous clear successes in the open source community, such as the Apache dominating position in the Web server market and Linux’s meteoric rise to become one of the world’s most popular operating systems.
But soon it became apparent this approach did work after all, as was evidenced by the rapid adoption of open source solutions for commonplace tasks such as code editing, FTP transfer, file compression, databasing, and word processing. The commercial software industry responded with overt attempts to discredit the competing open source competitors, highlighting feature deficiencies, scaling problems, lack of traditional user support, and anything else that would justify its products’ often hefty price tags.
Yet more recently, many traditional software developers are coming to the conclusion that a more cooperative attitude must be adopted if they are going to survive, let alone compete, in this brave new world. Many have even determined that open source is actually a beneficial part of the ecosystem and are making great strides toward not only making sure their software interoperates with open source projects but also offering considerable contributions by way of resources and even code.
One of the most exciting such instances of the opportunities that can arise from such efforts is the ability to use PHP, an open source project that also happens to be the world’s most popular programming language for dynamic Web development, with Oracle, a proprietary database that also happens to be the world’s most popular solution for managing data. Although for some time it has been possible to use PHP and Oracle together, only recently have these efforts really begun to pay off because of increased activities in both camps by way of not only improvements to the interface but also to the creation of learning resources, documentation, and other utilities.
It seems as with most things in life, the success of the software development industry does not
lie squarely within one extreme approach but rather somewhere in between. We hope this book will highlight the riches that can be wrought from a successful collaboration between the two.

Who This Book Is For

Although this book presumes the reader has no prior experience using PHP or Oracle, seasoned users of these technologies may find it equally satisfactory because the authors have strived to create a book that strikes a balance between tutorial and reference. Our goal is to provide you with a resource that can be repeatedly referred to as you progress from a novice to an experienced developer.

Although basic introductions are often provided, this book does not seek to teach you funda- mental programming concepts. After all, the book is not titled Beginning Programming with PHP and Oracle. And it does not teach you HTML and Cascading Style Sheets (CSS). If you are a program- ming novice or are not yet versed in the aforementioned Web technologies, consider picking up one or several of the fine Apress books covering these topics.

Beginning Google Maps Applications with PHP and Ajax

In the history of the Internet, 2005–2006 will be remembered as the year when online mapping finally came of age. Prior to 2005, MapQuest and other mapping services allowed you to look up directions, search for locations, and map businesses, but these searches were limited, usu- ally to the companies the services had partnered with, so you couldn’t search for any location. On February 8, 2005, Google changed all that. As it does with many of its services, Google qui- etly released the beta of Google Maps to its Labs incubator (http://labs.google.com) and let word-of-mouth marketing promote the new service.
By all accounts, Google Maps was an instant hit. It was the first free mapping service to provide satellite map views of any location on the earth, allowing anyone to look for familiar places. This started the “I can see my house from here” trend, and set the blogosphere abuzz with links to Google Maps locations around the world.
Like other mapping services, Google Maps offered directions, city and town mapping, and local business searches. However, what the Google Maps engineers buried within its code was something that quickly set it apart from the rest. Although unannounced and pos- sibly unplanned, they provided the means to manipulate the code of Google Maps to plot your own locations. Moreover, you could combine this base mapping technology with an external data source to instantly map many location-based points of information. And all of this could be done on privately owned domains, seemingly independent of Google itself.
At first, mapping “hackers” unlocked this functionality, just as video gamers hack into games by entering simple cheat codes. They created their own mapping services using Google Maps and other sources. One of the first these was Housingmaps.com, which combined the craigslist.org housing listings with a searchable Google Maps interface. Next came Adrian Holovaty’s chicagocrime.org, which offered a compelling way to view crime data logged by the Chicago Police Department. These home-brewed mapping applications were dubbed “hacks,” since Google had not sanctioned the use of its code in external domains on the Web.
The major change came in June 2005, when Google officially introduced the Google Maps API, which is the foundation for this book. By releasing this API, Google allowed programmers the opportunity to build an endless array of applications on top of Google Maps. Hundreds of API keys were registered immediately after the announcement, and many sites integrating Google Maps appeared within days. The map mashup was born.

The Birth of the Google Maps Mania Blog
The Google Maps labs beta site had been public for barely a month when I tried it for the first time. I was fascinated. While combing through the blogosphere looking for more information, I started to see a trend toward Google Maps hacks, how-to sites, Firefox extensions, and web-
sites indexing specific satellite images. I thought that others could benefit from an aggregation
of all of these ideas into one themed blog. Thus, my Google Maps Mania blog was born.

Google Maps Mania is more accurately described as a “meta-site,” as host Leo Laporte pointed out when I was a guest on his NPR G4techTV radio show in November 2005.
April 13, 2005, saw these as my first posts:

Title: Google Maps Mania

If you’re like me you were absolutely floored when Google came out with the Google Maps service. Sure, it’s just another mapping service. Until you realize it’s full potential. The ability to toggle between regular street/road maps and a satellite view is unreal. I’ve started to see a lot of buzz around the blogging community about Google Maps so I’ve decided to help you keep up with the Google Maps related sites, blogs and tools that are cropping up. Stay tuned.

Title: Google Sightseeing

The first Google Maps related site of note is Google Sightseeing. This blog tracks interest- ing satellite shots as submitted by its visitors, then organizes them by interest area like buildings, natural landmarks and stadiums. It’s a pretty nifty site. Google Sightseeing even posted my suggestion of Toronto’s Rogers Centre (Skydome) and the CN Tower!

Title: Flickr Memory Maps

Here’s a Flickr group that took off fast. Memory Maps is a Flickr group that contains maps with captions describing memories they have of those areas or specific notes about differ- ent areas. Kind of cool.

Title: Make your own multimedia Google map

Google Blogoscoped tipped me off on this link. Seems Engadget has a page which gives some pretty good directions on how to create your own annotated multimedia Google map. There is some pretty serious direction here which includes inserting pictures and movies from the annotations. I’d like to see an example of this.

Title: My GMaps

myGmaps enables you to create, save and host custom data files and display them with Google Maps. Create push-pin spots on any map of your choice. Mark your house, where an event will be held, or the route of a fun-run as a few examples. Then you can publish the map that you’ve created to your own website.

These postings represented an interesting cross-section of the ideas, concepts, and web- sites that I had come across in the two short months since Google Maps came to the Web. In the year between the start of Google Maps Mania and the release of the second-generation API
(which this book is based on) in April 2006, I have made over 900 posts and attracted more than
6,000 daily readers to the blog, including the architects of the API itself. I’ve been Slashdotted, Dug (at Digg), and linked to from the New York Times site, as well as the sites of hundreds of other mainstream papers and magazines. In June 2006, Google arranged for my entire family to travel across the country so I could speak at the Google Geo Developer Day in advance of the Where 2.0 conference.

So many interesting mashups have been created using the Google Maps API that it’s becoming impossible to keep up with all of them. I liken this to the early days of the Web when search directories began to manually catalog new web pages as they came online. The volume of new sites quickly became too huge to handle manually, and Google itself was born.
You can see why the Google Maps API offers the key for the next killer apps on the Web. It has been the missing link to take the Web to the next level.
This book will provide you the means to take part in this evolution of the Web. I hope to be posting about the interesting and unique map creations that you build after reading this book. Your creations will inspire others to do similar things, and together, we will continue to grow the Internet, one mapping application at a time. Let me know if you build something cool!

MICHAEL PURVIS is a Mechatronics Engineering student at the University of Waterloo, in Ontario. He is a mostly self-taught pro- grammer. Prior to discovering PHP, he was busy making a LEGO® Mindstorms kit play Connect 4. Currently, he maintains an active community site for classmates, built mostly from home-brewed extensions to PunBB and MediaWiki.
He has written about CSS for Position Is Everything, and occa- sionally participates in the css-discuss mailing list. He particularly enjoys those clever layouts that mix negative margins, relative posi- tioning, and bizarre float tricks to create fiendish, cross-browser, flexible-width concoctions. These and other nontechnical topics
are discussed on his weblog at uwmike.com.
Offline, he enjoys cooking, cycling, and social dancing. He has worked with We-Create, Inc. on a number of PHP-based projects, and has a strong interest in independent web standards.

JEFFREY SAMBELLS is a graphic designer and self-taught web appli- cations developer best known for his unique ability to merge the visual world of graphics with the mental realm of code. With a Bachelor of Technology degree in Graphic Communications Man- agement along with a minor in Multimedia, Jeffrey was originally trained for the traditional paper-and-ink printing industry, but he soon realized the world of pixels and code was where his ideas would prosper. In late 1999, he cofounded We-Create, Inc., an Inter- net software company based in Waterloo, Ontario, which began many long nights of challenging and creative innovation. Currently, as Director of Research and Development for We-Create, Jeffrey is
responsible for investigating new and emerging Internet technologies and integrating them using web standards-compliant methods. In late 2005, he also became a Zend Certified Engineer.
When not playing at the office, Jeffrey enjoys a variety of hobbies from photography to woodworking. When the opportunity arises, he also enjoys floating in a canoe on the lakes of Algonquin Provincial Park or going on an adventurous, map-free, drive with his wife. Jeffrey also maintains a personal website at JeffreySambells.com, where he shares thoughts, ideas, and opinions about web technologies, photography, design, and more. He lives in Ontario,
Canada, eh, with his wife, Stephanie, and their little dog, Milo.

CAMERON TURNER has been programming computers since his first
VIC 20 at age 7. He has been developing interactive websites since
1994. In 1999, he cofounded We-Create, Inc., which specializes in Internet software development. He is now the company’s Chief Technology Officer. Cam obtained his Honors degree in Computer Science from the University of Waterloo with specialization in applied cryptography, database design, and computer security.
Cam lives in Canada’s technology capital of Waterloo, Ontario, with his wife, Tanya, son Owen, and dog Katie. His hobbies include biking, hiking, water skiing, and painting. He maintains a personal blog at CamTurner.com, discussing nontechnical topics, thoughts, theories, and family life.

AJAX and PHP Building Responsive Web Applications

Enhance the user experience of your PHP website using AJAX with this practical tutorial featuring detailed case studies

Cristian Darie is a software engineer with experience in a wide range of modern technologies, and the author of numerous technical books, including the popular "Beginning E-Commerce" series. Having worked with computers since he was old enough to press the keyboard, he initially tasted programming success with a first prize in his first programming contest at the age of 12. From there, Cristian moved on to many other similar achievements, and now he is studying distributed application architectures for his PhD degree. He always loves hearing feedback about his books, so don't hesitate dropping a "hello" message when you have a spare moment.

Filip Cherecheş-Toşa is a web developer with a firm belief in the future of web-based software. He started his career at the age of 9, when he first got a Commodore 64 with tape-drive.

Back home in Romania, Filip runs a web development company named eXigo www.exigo.ro, which is actively involved in web-based application development and web design. He is currently a student at the University of Oradea, studying Computer Science, and also an active member of the Romanian PHP Community www.phpromania.net.

Mihai Bucica started programming and competing in programming contests (winning many of them), all at age twelve. With a bachelor's degree in computer science from the Automatic Control and Computers Faculty of the Politehnica University of Bucharest, Romania, Bucica works on building communication software with various electronic markets.

Even after working with a multitude of languages and technologies, Bucica's programming language of choice remains C++, and he loves the LGPL word. Mihai also co-authored Beginning PHP 5 and MySQL E-Commerce and he can be contacted through his personal website, www.valentinbucica.ro.

Emilian Balanescu is a programmer experienced in many technologies, including PHP, Java,
.NET, PostgreSQL, MS SQL Server, MySQL, and others. He currently works as a Wireless
Network Administrator at accessNET International S.A. Romania, a company that provides fixed wireless access services operating a point-to-multipoint digital radio communication network with national coverage. His latest project in this position was developing an AJAX-enabled real-time Network Management System (using SNMP, Perl, PHP, and PostgreSQL) used for remote debugging, monitoring system performance, and isolating and troubleshooting system problems. You can reach Emilian at http://www.emilianbalanescu.ro.

Paula Badascu is in the third year of studies at Politehnica University of Bucharest, one of the most famous technical universities in Romania, studying Electronics, Telecommunications, and Information Technology. Paula is currently working as an analyst/programmer for NCH Advisors Romania, building web applications using UML, OOP, PHP, SQL, JavaScript, and CSS. She contributed decisively to the analysis and development of a framework used for tracking and monitoring the Romanian capital market.

AJAX is a complex phenomenon that means different things to different people. Computer users appreciate that their favorite websites are now friendlier and feel more responsive. Web developers learn new skills that empower them to create sleek web applications with little effort. Indeed, everything sounds good about AJAX!

At its roots, AJAX is a mix of technologies that lets you get rid of the evil page reload, which represents the dead time when navigating from one page to another. Eliminating page reloads is just one step away from enabling more complex features into websites, such as real-time data validation, drag and drop, and other tasks that weren't traditionally associated with web applications. Although the AJAX ingredients are mature (the XMLHttpRequest object, which is the heart of AJAX, was created by Microsoft in 1999), their new role in the new wave of web trends is very young, and we'll witness a number of changes before these technologies will be properly used to the best benefit of the end users. At the time of writing this book, the "AJAX" name is about just one year old.

AJAX isn't, of course, the answer to all the Web's problems, as the current hype around it may suggest. As with any other technology, AJAX can be overused, or used the wrong way. AJAX also comes with problems of its own: you need to fight with browser inconsistencies,
AJAX-specific pages don't work on browsers without JavaScript, they can't be easily bookmarked by users, and search engines don't always know how to parse them. Also, not everyone likes AJAX. While some are developing enterprise architectures using JavaScript, others prefer not to use it at all. When the hype is over, most will probably agree that the middle way is the wisest way to go for most scenarios.

In AJAX and PHP: Building Responsive Web Applications, we took a pragmatic and safe approach by teaching relevant patterns and best practices that we think any web developer will need sooner or later. We teach you how to avoid the common pitfalls, how to write efficient AJAX code, and how to achieve functionality that is easy to integrate into current and future web applications, without requiring you to rebuild the whole solution around AJAX. You'll be able to use the knowledge you learn from this book right away, into your PHP web applications.

We hope you'll find this book useful and relevant to your projects. For the latest details and updates regarding this book, please visit its mini-site at http://ajaxphp.packtpub.com.

The book's mini-site also contains additional free chapters and resources, which we recommend you check out when you have the time.

Chapter 1: AJAX and the Future of Web Applications is an initial incursion into the world of AJAX and the vast possibilities it opens up for web developers and companies, to offer a better experience to their users. In this chapter you'll also build your first AJAX-enabled web page, which will give you a first look of the component technologies.

Chapter 2: Client-Side Techniques with Smarter JavaScript will guide you through the technologies you'll use to build AJAX web clients, using JavaScript, the DOM, the XMLHttpRequest object, and XML. While not being a complete tutorial for these technologies, you'll be put on the right track for using them together to build a solid foundation for your future applications.

Chapter 3: Server-Side Techniques with PHP and MySQL completes the theoretical foundation by presenting how to create smart servers to interact with your AJAX client. You'll learn various techniques for implementing common tasks, including handling basic JavaScript security and
error-handling problems.

Chapter 4: AJAX Form Validation guides you through creating a modern, responsive, and secure form validation system that implements both real-time AJAX validation and server-side validation on form submission.

Chapter 5: AJAX Chat presents a simple online chat that works exclusively using AJAX code, without using Java applets, Flash code, or other specialized libraries as most chat applications do these days.

Chapter 6: AJAX Suggest and Autocomplete builds a Google Suggest-like feature, that helps you quickly find PHP functions, and forwards you to the official help page for the chosen function.

Chapter 7: AJAX Real-Time Charting with SVG teaches you how to implement a real-time charting solution with AJAX and SVG. SVG (Scalable Vector Graphics) is a text-based graphics language that can be used to draw shapes and text.

Chapter 8: AJAX Grid teaches you how to build powerful AJAX-enabled data grids. You'll learn how to parse XML documents using XSLT to generate the output of your grid.

Chapter 9: AJAX RSS Reader uses the SimpleXML PHP library, XML, and XSLT to build a simple RSS aggregator.

Chapter 10: AJAX Drag and Drop is a demonstration of using the script.aculo.us framework to build a simple list of elements with drag-and-drop functionality.

Advanced PHP Programming By George Schlossnagle

Over the past three years PHP has evolved from being a niche language used to add dynamic functionality to small sites to a powerful tool making strong inroads into large-scale, business-critical Web systems.

The rapid maturation of PHP has created a skeptical population of users from more traditional "enterprise" languages who question the readiness and ability of PHP to scale, as well as a large population of PHP developers without formal computer science backgrounds who have learned through the hands-on experimentation while developing small and midsize applications in PHP.

George Schlossnagle is a principal at OmniTI Computer Consulting, a Maryland-based tech company that specializes in high-volume Web and email systems. Before joining OmniTI, he led technical operations at several high-profile community Web sites, where he developed experience managing PHP in very large enterprise environments. He is a frequent contributor to the PHP community and his work can be found in the PHP core, as well as in the PEAR and PECL extension repositories.

Before entering the information technology field, George trained to be a mathe-matician and served a two-year stint as a teacher in the Peace Corps. His experience has taught him to value an interdisciplinary approach to problem solving that favors root-cause analysis of problems over simply addressing symptoms.

While there are many books on learning PHP and developing small applications with it, there is a serious lack of information on "scaling" PHP for large-scale, business-critical systems. Schlossnagle's Advanced PHP Programming fills that void, demonstrating that PHP is ready for enterprise Web applications by showing the reader how to develop PHP-based applications for maximum performance, stability, and extensibility.

THIS BOOK STRIVES TO MAKE YOU AN expert PHP programmer. Being an expert programmer does not mean being fully versed in the syntax and features of a language (although that helps); instead, it means that you can effectively use the language to solve problems. When you have finished reading this book, you should have a solid understanding of PHP's strengths and weaknesses, as well as the best ways to use it to tackle problems both inside and outside the Web domain.

This book aims to be idea focused, describing general problems and using specific examples to illustrateas opposed to a cookbook method, where both the problems and solutions are usually highly specific. As the proverb says: "Give a man a fish, he eats for a day. Teach him how to fish and he eats for a lifetime." The goal is to give you the tools to solve any problem and the understanding to identify the right tool for the job.

In my opinion, it is easiest to learn by example, and this book is chock full of practical examples that implement all the ideas it discusses. Examples are not very useful without context, so all the code in this book is real code that accomplishes real tasks. You will not find examples in this book with class names such as Foo and Bar; where possible, examples have been taken from live open-source projects so that you can see ideas in real implementations.

When I started programming PHP professionally in 1999, PHP was just starting its emergence as more than a niche scripting language for hobbyists. That was the time of PHP 4, and the first Zend Engine had made PHP faster and more stable. PHP deployment was also increasing exponentially, but it was still a hard sell to use PHP for large commercial Web sites. This difficulty originated mainly from two sources:

Perl/ColdFusion/other-scripting-language developers who refused to update their understanding of PHP's capabilities from when it was still a nascent language.

Java developers who wanted large and complete frameworks, robust object-oriented support, static typing, and other "enterprise" features.

Neither of those arguments holds water any longer. PHP is no longer a glue-language used by small-time enthusiasts; it has become a powerful scripting language whose design makes it ideal for tackling problems in the Web domain.

A programming language needs to meet the following six criteria to be usable in business-critical applications:

Fast prototyping and implementation

Support for modern programming paradigms

Scalability

Performance

Interoperability

Extensibility

The first criterionfast prototypinghas been a strength of PHP since its inception. A critical difference between Web development and shrink-wrapped software development is that in the Web there is almost no cost to shipping a product. In shipped software products, however, even a minor error means that you have burned thousands of CDs with buggy code. Fixing that error involves communicating with all the users that a bug fix exists and then getting them to download and apply the fix. In the Web, when you fix an error, as soon as a user reloads the page, his or her experience is fixed. This allows Web applications to be developed using a highly agile, release-often engineering methodology.

Scripting languages in general are great for agile products because they allow you to quickly develop and test new ideas without having to go through the whole compile, link, test, debug cycle. PHP is particularly good for this because it has such a low learning curve that it is easy to bring new developers on with minimal previous experience.

PHP 5 has fully embraced the rest of these ideas as well. As you will see in this book, PHP's new object model provides robust and standard object-oriented support. PHP is fast and scalable, both through programming strategies you can apply in PHP and because it is simple to reimplement critical portions of business logic in low-level languages. PHP provides a vast number of extensions for interoperating with other servicesfrom database servers to SOAP. Finally, PHP possesses the most critical hallmark of a language: It is easily extensible. If the language does not provide a feature or facility you need, you can add that support.