Home Web Development PHP Oracle Web Development: Data processing, Security, Caching, XML, Web Services, and Ajax

PHP Oracle Web Development: Data processing, Security, Caching, XML, Web Services, and Ajax

By Yuli Vasiliev
books-svg-icon Book
Subscription FREE
eBook + Subscription $15.99
eBook $32.99
Print + eBook $54.99
READ FOR FREE Free Trial for 7 days. $15.99 p/m after trial. Cancel Anytime! BUY NOW BUY NOW BUY NOW
What do you get with a Packt Subscription?
This book & 7000+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook + Subscription?
Download this book in EPUB and PDF formats
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook?
Download this book in EPUB and PDF formats
Access this title in our online reader
DRM FREE - Read whenever, wherever and however you want
Online reader with customised display settings for better reading experience
What do you get with video?
Download this video in MP4 format
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with Audiobook?
Download a zip folder consisting of audio files (in MP3 Format) along with supplementary PDF
READ FOR FREE Free Trial for 7 days. $15.99 p/m after trial. Cancel Anytime! BUY NOW BUY NOW BUY NOW
Subscription FREE
eBook + Subscription $15.99
eBook $32.99
Print + eBook $54.99
What do you get with a Packt Subscription?
This book & 7000+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook + Subscription?
Download this book in EPUB and PDF formats
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook?
Download this book in EPUB and PDF formats
Access this title in our online reader
DRM FREE - Read whenever, wherever and however you want
Online reader with customised display settings for better reading experience
What do you get with video?
Download this video in MP4 format
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with Audiobook?
Download a zip folder consisting of audio files (in MP3 Format) along with supplementary PDF
  1. Free Chapter
    Getting Started with PHP and Oracle
About this book
Oracle Database gets high marks for performance, reliability, and scalability. Building and deploying your PHP applications on Oracle Database enables you to combine the power and robustness of Oracle and the ease of use, short development time, and high performance of PHP. When used in a complementary way, PHP and Oracle allow you to build high-performance, scalable, and reliable data-driven Web applications with a minimum of effort.When building a PHP/Oracle application, you have two general options. The first is to use an Oracle database just to store data, performing all the operations on that data on the client side; the other is to use the database not only to store data, but also to process it, thus moving data processing to the data. While building the key business logic of a database-driven PHP application inside the database is always a good idea, you should bear in mind that not all of the databases available today allow you to do. The Oracle database, which offers record-breaking performance, scalability, and reliability, does. The partnership of Oracle and the open-source scripting language PHP is an excellent solution for building high-performance, scalable, and reliable data-driven web applications.This 100% practical book is crammed full of easy-to-follow examples. It provides all the tools a PHP/Oracle developer needs to take advantage of the winning combination. It addresses the needs of a wide spectrum of PHP/Oracle developers, placing the emphasis on the most up-to-date topics, such as new PHP and Oracle Database features, stored procedure programming, handling transactions, security, caching, web services, and Ajax.
Publication date:
July 2007
Publisher
Packt
Pages
396
ISBN
9781847193636

 

Chapter 1. Getting Started with PHP and Oracle

There are two kinds of database-driven applications. Ones that use databases just to store data, performing all the operations on it on the client side; and the others that use databases not only to store data, but also to process it, thus moving data processing to the data. While building the key business logic of a database-driven application inside the database is always a good idea, you should bear in mind that not all the databases available today allow you to put this into practice. However, the Oracle database offers record‑breaking performance, scalability, and reliability. The partnership formed by Oracle and PHP, an open-source scripting language, is an excellent solution for building high-performance, scalable, and reliable data-driven web applications.

This chapter contains technical information that will help you to quickly start developing PHP applications on top of Oracle. It begins with a concise discussion of why you might want to use PHP in conjunction with Oracle, followed by the PHP and Oracle alternatives. Having learned what advantages the PHP/Oracle combination has over its competitors, you might want to see its strengths in action. If you don't have PHP and Oracle database software installed, you can read the What You Need to Start section in this chapter. This section discusses the pieces of software required to run the examples provided in this book. You could also read Appendix A Installing PHP and Oracle Software, which provides a quick-and-dirty guide to installing and configuring these software components to work together in your system.

Once you have all the required pieces of software installed, configured, and working properly, you are ready to build your first PHP/Oracle application. For the sake of simplicity, the sample application provided in this chapter simply obtains the current time from the database and then displays it to the user. In spite of its simplicity, the example demonstrates how to perform two basic things that every PHP/Oracle application must take care of. Specifically, it demonstrates how a PHP application can connect to an Oracle database and then interact with it.

If you have already got your feet wet with PHP/Oracle development, you probably will not be interested in reading this quick-start chapter. If so, you can move to Chapter 2, which discusses how to use PHP's OCI8 extension, providing a common way to interact with Oracle database from PHP.

Why PHP and Oracle?

With Oracle as the back-end database, you can develop and deploy data-driven PHP applications with a powerful, proven, and industry-leading infrastructure, while still taking advantage of PHP's ease of use, short development time, and high performance.

Simplicity and Flexibility

One of the key reasons behind PHP's popularity is its simplicity. So, you don't have to be a PHP guru to start building PHP applications on Oracle. All you need to learn are a few APIs, which allow you to interact with the database and handle the received data. The example discussed later in this chapter will show you how to build a simple PHP/Oracle application by using a few OCI8 functions.

PHP's Object-Oriented features, available since PHP 3 and significantly improved in PHP 5, help you create complex applications easily and quickly. Once a class has been written and debugged, you can reuse it in a number of ways. This allows you to reuse well‑designed pieces of object-oriented code over and over, reducing or eliminating redundant code in your applications. For a detailed discussion of how to combine the power of object-oriented PHP and Oracle, refer to Chapter 5

From a PHP developer's perspective, developing PHP/Oracle applications is much easier than developing, PHP/MySQL applications. This is because, in the case of Oracle database, you may implement key business logic of the application on the database side. This not only reduces the amount of PHP code, but also improves the performance and scalability of the entire application.

If you are a PHP developer who tends to think that Oracle database represents a complicated, hard-to-drive mechanism, you should realize that—no matter how complex the Oracle insides may be—what really matters is that Oracle offers a lot of comprehensive tools intended to help you manage database objects and access data stored in the database with minimum effort. Although coverage of all the tools is beyond the scope of this book, the examples provided throughout the book will help you to obtain a good understanding of how Oracle SQL and PL/SQL—two of the most popular Oracle tools—are used to access and manipulate data, metadata, and other database resources.

Performance

Although you can process your application data on the client side in the case of Oracle database, there are many advantages of processing data inside the database. From a performance standpoint, moving processing to the data allows you to:

  • Reduce the communication overhead between the web server and the database

  • Conserve the web server resources

  • Take advantage of optimizations and indexing techniques provided by the Oracle database

By using triggers and stored procedures, you can develop an application whose business logic resides entirely inside the database. Moving data processing to the database tier is particularly useful if your application is database intensive. This is because your application doesn't need to transfer a large amount of data between tiers while processing data inside the database; instead, it sends only the final product across the wire.

Robustness

Oracle gets high marks when it comes to performance, reliability, and scalability. Building and deploying your PHP applications on Oracle database enables you to combine the power and robustness of Oracle and the ease of use, short development time, and high performance of PHP. By using both of these technologies in a complementary way, you will be able to:

  • Move key business logic of your application to the data

  • Protect your application against data loss

  • Take advantage of Oracle security technologies

  • Leverage the power of object-oriented technology

  • Build transactional applications

  • Develop robust XML-enabled applications

All these capabilities make using PHP in conjunction with Oracle a natural choice when it comes to developing mission-critical, highly secure data-driven web applications.

 

Why PHP and Oracle?


With Oracle as the back-end database, you can develop and deploy data-driven PHP applications with a powerful, proven, and industry-leading infrastructure, while still taking advantage of PHP's ease of use, short development time, and high performance.

Simplicity and Flexibility

One of the key reasons behind PHP's popularity is its simplicity. So, you don't have to be a PHP guru to start building PHP applications on Oracle. All you need to learn are a few APIs, which allow you to interact with the database and handle the received data. The example discussed later in this chapter will show you how to build a simple PHP/Oracle application by using a few OCI8 functions.

PHP's Object-Oriented features, available since PHP 3 and significantly improved in PHP 5, help you create complex applications easily and quickly. Once a class has been written and debugged, you can reuse it in a number of ways. This allows you to reuse well‑designed pieces of object-oriented code over and over, reducing or eliminating redundant code in your applications. For a detailed discussion of how to combine the power of object-oriented PHP and Oracle, refer to Chapter 5

From a PHP developer's perspective, developing PHP/Oracle applications is much easier than developing, PHP/MySQL applications. This is because, in the case of Oracle database, you may implement key business logic of the application on the database side. This not only reduces the amount of PHP code, but also improves the performance and scalability of the entire application.

If you are a PHP developer who tends to think that Oracle database represents a complicated, hard-to-drive mechanism, you should realize that—no matter how complex the Oracle insides may be—what really matters is that Oracle offers a lot of comprehensive tools intended to help you manage database objects and access data stored in the database with minimum effort. Although coverage of all the tools is beyond the scope of this book, the examples provided throughout the book will help you to obtain a good understanding of how Oracle SQL and PL/SQL—two of the most popular Oracle tools—are used to access and manipulate data, metadata, and other database resources.

Performance

Although you can process your application data on the client side in the case of Oracle database, there are many advantages of processing data inside the database. From a performance standpoint, moving processing to the data allows you to:

  • Reduce the communication overhead between the web server and the database

  • Conserve the web server resources

  • Take advantage of optimizations and indexing techniques provided by the Oracle database

By using triggers and stored procedures, you can develop an application whose business logic resides entirely inside the database. Moving data processing to the database tier is particularly useful if your application is database intensive. This is because your application doesn't need to transfer a large amount of data between tiers while processing data inside the database; instead, it sends only the final product across the wire.

Robustness

Oracle gets high marks when it comes to performance, reliability, and scalability. Building and deploying your PHP applications on Oracle database enables you to combine the power and robustness of Oracle and the ease of use, short development time, and high performance of PHP. By using both of these technologies in a complementary way, you will be able to:

  • Move key business logic of your application to the data

  • Protect your application against data loss

  • Take advantage of Oracle security technologies

  • Leverage the power of object-oriented technology

  • Build transactional applications

  • Develop robust XML-enabled applications

All these capabilities make using PHP in conjunction with Oracle a natural choice when it comes to developing mission-critical, highly secure data-driven web applications.

 

Exploring PHP and Oracle Alternatives


Now that you have a rough idea of what the PHP/Oracle combination has to offer, it is worth taking a moment to familiarize yourself with some other popular combinations that can be used as alternatives to PHP and Oracle. Exploring such alternatives, including their advantages and disadvantages, can help you understand better whether PHP and Oracle best suit your needs or there is another combination that suits your needs better.

Although PHP supports all the major relational databases, including commercial ones such as IBM's DB2 and Microsoft SQL Server, MySQL, an open-source database, is still a popular choice among PHP developers. The major reason behind MySQL's popularity is that it is completely free under the GPL license.

Of those based on Oracle, JSF and Oracle is probably one of the most powerful combinations available. To make JSF/Oracle application development easier, Oracle offers ADF Faces, a fully compliant JSF component library including over 100 JSF components.

PHP and MySQL

MySQL is extremely popular among the open‑source community that uses PHP. There are several reasons behind MySQL's popularity among PHP developers. The most significant ones are as follows:

  • Completely free under the GPL license

  • Low Total Cost of Ownership (TOC)

  • PHP natively supports MySQL—no additional modules are required

All these factors make MySQL a natural choice for web hosts providing support for PHP. However, you should realize that the PHP/MySQL combination is a good solution for small data-driven web applications whereas professional-quality applications require much more.

JSF and Oracle

JavaServer Faces technology is a new server-side user interface (UI) component framework that is quickly becoming the standard web-application framework for J2EE applications. The biggest advantage of JavaServer Faces technology is that it enables web developers to apply the Model-View-Controller (MVC) principle, thus achieving a clean separation between the model and presentation layers of a web application. The entire user interaction with the application is handled by a front-end Faces servlet.

The only disadvantage the JSF and Oracle combination has compared to PHP and Oracle is that JavaServer Faces is a bit more difficult to learn than PHP.

     
About the Author
  • Yuli Vasiliev

    Yuli Vasiliev is a software developer, freelance author, and consultant currently specializing in open-source development, Oracle technologies, and service-oriented architecture (SOA). He has over 10 years of software development experience as well as several years of technical writing experience. He wrote a series of technical articles for Oracle Technology Network (OTN) and Oracle Magazine. Contact Yuli Vasiliev

    Browse publications by this author
Latest Reviews (1 reviews total)
Still working through the book and I found the book to be exactly watt I needed.
PHP Oracle Web Development: Data processing, Security, Caching, XML, Web Services, and Ajax
Unlock this book and the full library FREE for 7 days
Start now