PHP Data Abstraction - PowerPoint PPT Presentation

1 / 11
About This Presentation
Title:

PHP Data Abstraction

Description:

ADOdb is a database abstraction layer for PHP. ... It can takes advantage of specific database features, increasing application performance. ... – PowerPoint PPT presentation

Number of Views:45
Avg rating:3.0/5.0
Slides: 12
Provided by: techm3
Category:

less

Transcript and Presenter's Notes

Title: PHP Data Abstraction


1
PHP Data Abstraction
  • Clean out the CRUD

2
Intro
  • PHP  allows us to very easily and quickly connect
    to, query and return results from any number of
    different databases, including mysql, postgresql,
    sqllite and even MSSQL. This flexibility in php
    makes it a powerful tool, and unfortunately a
    quick way to get into trouble.   We have all
    written Create, Retrieve, Update, Delete code in
    PHP before, whether in a form, an administration
    system for news articles, or maybe a home grown
    e-commerce system.  Having written this code you
    have at some point had to go back in to debug,
    add features, change functionality.   Typically
    most of these interactions with your own code are
    somewhat painless (assuming comments and well
    formated code) and you can trace your way through
    well enough to make changes or to troubleshoot.

3
What is Data Abstraction
  • A database abstraction layer provides a
    database-independent interface to developers
    working on different databases. Perl has one, and
    now PHP has one too, courtesy of PEAR and ADOdb.
    Though an abstraction layer can take a little
    getting used to, it offers tremendous benefits in
    the long run, especially if you expect platform
    or database changes during the development cycle.
    Using an abstraction layer can significantly
    reduce the amount of time you spend porting your
    code over from one database to another.
  • The available PHP abstraction layer currently
    includes support for a number of different
    database types, including MySQL, PostgreSQL,
    Oracle, Sybase and ODBC. In addition to
    frequently-used methods for executing queries and
    fetching resultsets, the PEAR abstraction layer
    also supports pre-prepared queries, transactions
    and customized error handling. A number of
    miscellaneous utility functions are also included
    to assist in query execution and data retrieval.

4
ADOdb
  • ADOdb is a database abstraction layer for PHP.
    There are many advantages of using a database
    abstraction layer instead of the native database
    functions in PHP.
  • The main advantage is that your project can
    support multiple databases. You don't have to
    lock your users into the database you prefer,
    instead they can use the database they prefer to
    use. This increases the potential user base for
    your project.
  • Another key advantage is that it provides you
    with a standard, unified set of commands to use
    with all databases that PHP supports. If you
    change databases you don't have to deal with
    learning different functions each time. Also, due
    to this, the data is returned in the same format
    each time no matter which database you are using.
    ADOdb returns the data as a two-dimensional array
    which you can manipulate any way you want. Using
    a two-dimensional array gives you much more
    flexibility to do what you want with the data.

5
Why this is Good
  • It reduces the coupling between your object
    schema and your data schema, increasing your
    ability to evolve either one.
  • It implements all data-related code in one place.
  • It simplifies the job of application programmers
    and code maintainers.
  • It allows application programmers to focus on
    the business problem in one area while focusing
    on data access on the database in another.
  • It gives you a common place to implement
    data-oriented business rules.
  • It can takes advantage of specific database
    features, increasing application performance.
  • Makes changing database schemas or even database
    vendors much easier to implement

6
Different Types
  • People sometimes say SQL abstraction layer or
    database interface fairly loosely, assuming
    everyo knows what they mean. Not so Ive seen
    at least four distinct meanings in common usage
  • 1. A software library to connect to a database
    server and issue queries, fetch results etc.
  • 2. A software library to present a common API
    to different database servers.
  • 3. A software library to automatically
    generate portable SQL queries.
  • 4. A software library to map Object-Oriented
    Programming to a relational database
    (Object-Relational Mapping, or ORM)

7
Lets look
8
Looking
9
Looking
10
Looking
11
With Smarty !
Write a Comment
User Comments (0)
About PowerShow.com