There are various ways PHP can connect to Oracle. Although this book concentrates on the
OCI8 extension for PHP, it is worth knowing the alternative libraries and extensions you can
use.

Choosing a PHP Oracle Extension

Several PHP extensions provide PHP functions for accessing Oracle databases and there are
also database abstraction layers written in PHP which are popular. You can also use the
ODBC extension.
If you want to make full use of Oracle features and want high performance use PHP’s
main Oracle extension, the OCI8 extension. If you want database independence, consider
using the PHP Data Object (PDO) extension or ADOdb. For basic database operations your
PHP application will work with different database vendors simply by changing the extension
driver.
Basic database access in each extension and abstraction library is very similar. The
differences are in their support for advanced features and the programming methodology
promoted.

PHP Oracle Extensions

The PHP Oracle extensions can be compiled into the PHP binary. The extensions are:
* Oracle
* OCI8
* PDO
They are all included in the PHP source code with PHP’s open source license.
Oracle Extension
The extension called “Oracle” was included in PHP 3, 4 and 5.0. It had limited functionality,
is no longer in PHP and is not maintained. This extension accessed the database using
Oracle’s obsolete C code OCI7 API. New development using this extension is not
recommended.

OCI8 Extension

The OCI8 extension is included in PHP 3, 4, and 5. It is also in PHP 6, which is in the early
stage of development.
For PHP 5.1.2, OCI8 was refactored by Zend and Oracle to increase stability and
performance, and released as open source. The PHP interfaces are the same as the original
OCI8 extension but there are new connection management and performance settings.

PHP is a hugely popular, interpreted scripting language commonly used for web applications.
PHP is open source and free, and has a BSD-style license, making it corporation-friendly.
PHP is perfect for rapidly developing applications both big and small, and is great for
creating Web 2.0 applications. It powers over twenty million web sites on the Internet and
has a huge user community behind it. It runs on many platforms.
The language is dynamically typed and easy to use. PHP comes with many extensions
offering all kinds of functionality such as database access. PHP 5 introduced strong object
orientated capabilities.
PHP code is commonly embedded in HTML:
Hello

";
?>

World


PHP is typically installed as an Apache module, or run by the web server using FastCGI.
When the PHP parser processes a file, it executes the PHP code and outputs any results. The
HTML sections are echoed to the web browser verbatim. The HTML output from the above
script would therefore be:

Hello

World


The PHP command line interface (CLI) can also be used to run PHP scripts from an
operating system shell window.

Schemas and Users

Posted by Whiz 0 comments
A schema is a collection of database objects such as tables and indexes. A schema is owned
by a database user and has the same name as that user. Many people use the words schema
and user interchangeably.
Once you have installed PHP and want to write scripts that interact with Oracle, you need
to connect as the owner of the schema that contains the objects you want to interact with. For
example, to connect to the HR schema, you would use the username hr in PHP’s connection
string.
Some of the most common schema objects are:
* Tables
* Indexes
* Views
Although you may have more than one database per machine, typically a single Oracle
database contains multiple schemas. Multiple applications can use the same database without
any conflict by using different schemas. Instead of using a CREATE DATABASE command for
new applications, use the CREATE USER command to create a new schema in the database. In
Oracle Database Express Edition (known as “Oracle XE”) there is a wizard to create new
users in the Application Express management console.

Tablespaces

Posted by Whiz 0 comments
Tablespaces are the logical units of data storage made up of one or more datafiles.
Tablespaces are often created for individual applications because tablespaces can be
conveniently managed. Users are assigned a default tablespace that holds all the data the
users creates. A database is made up of default and DBA-created tablespaces.

An Oracle database stores and retrieves data. Each database consists of one or more data
files. An Oracle database server consists of an Oracle database and an Oracle instance.
Every time a server is started, a shared memory region called the system global area (SGA) is
allocated and the Oracle background processes are started. The combination of the
background processes and SGA is called an Oracle instance. On some operating systems, like
Windows, there are no separate background processes. Instead threads run within the Oracle
image.

The Oracle Database is well known for its scalability, reliability and features. It is the leading
database and is available on many platforms.

There are some subtle differences between the terminology used when describing an
Oracle database and a database from other software vendors. The following overview of the
main Oracle terms might help you to understand the Oracle terminology. Check the Glossary
for more descriptions.