|
|
|
|
| |
That's the theory, anyway. However, you should be aware of two factors that work against DBI script portability:
SQL implementations differ between RDBMS engines, and it's perfectly possible to write SQL statements for one engine that another will not understand. If your SQL is reasonably generic, your scripts will be correspondingly portable between engines. But if your SQL is engine dependent, your scripts will be too. For example, if you use the MySQL-specific SHOW TABLES statement, your script won't work with other databases.
DBD modules often provide engine-specific types of information to allow script writers to use particular features of particular database systems. As an example of this, the MySQL DBD provides a way to access properties of the columns in a query result, such as the maximum length of values in each column, whether or not columns are numeric, and so forth. These properties don't necessarily have any analog in other databases. DBD-specific features are antithetical to portability; by using them, you make it difficult to use a script written for MySQL with other database systems.
Despite the potential of these two factors for making your scripts database specific, the DBI mechanism for providing database access in an abstract fashion is a reasonable means of achieving portability. It's up to you to decide how much you want to take advantage of non-portable features. As you will discover in Chapter 7, "The Perl DBI API," I make little effort to avoid MySQL-specific constructs provided by the MySQL DBD, and all of them are listed in Appendix G, "Perl DBI API Reference." That's because you should know what those constructs are so that you can decide for yourself whether or not to use them.
The Meaning of DBI and DBD
Although the DBI level is database independent and the DBD level is database dependent, that isn't what "DBI" and "DBD" stand for. They mean "database interface" and "database driver."
The PHP API
Like Perl, PHP is a scripting language. Unlike Perl, PHP is designed less as a general-purpose language than as a language for writing Web applications. The PHP API is used primarily as a means of embedding executable scripts into Web pages. This makes it easy for Web developers to write pages with dynamically generated content. When a client browser sends a request for a PHP page to a Web server, PHP executes any script it finds in the page and replaces it with the script's output. The result is sent to the browser. This allows the page that actually appears in the browser to change according to the circumstances under which the page is requested. For example, when the following short PHP script is embedded in a Web page, it displays the IP address of the host that requested the page
|
|
|
|
|
|
| Link Partners: Asia florist, Flowers to India, Hong kong flowers, Site submit, Cheap web hosting, China florist, Japan florist |
|