Developing IBM Cloudscape and DB2 common database applications in PHP

Source: Internet
Author: User
Tags db2 db2 client ibm db2 php language odbc php script microsoft iis linux


Using a unified ODBC extension with Apache 2 PHP



Introduction: Learn how to configure the ibm®cloudscape™10.0 and IBM db2®universal database™ (DB2 UDB) Version 8.2 Server for access from PHP 4.x and PHP 5.x. Write database applications using a unified ODBC extension. Overcome common performance problems caused by scrollable cursors and avoid functional limitations in stored procedures. The unified ODBC Extension of PHP provides a common interface for developing PHP applications that connect to databases through Open Database connectivity (open DB CONNECTIVITY,ODBC) drivers. The DB2 client includes an ODBC driver that allows you access to Apache Derby, Cloudscape, DB2 udb for Linux™, Unix®and Windows®, and DB2 udb for Iseries™and Z series® the data in the server. Even better, you can compile the unified ODBC extension directly on the DB2 invocation-level interface (DB2 call levels interface,db2 CLI) so that the PHP application avoids the ODBC Driver Manager overhead and communicates directly with the target database server.



Introduction to PHP: Hypertext processor



PHP: A hypertext processor (Php:hypertext Processor), a powerful and increasingly popular server-side scripting language for creating Web content. Portability is one of the main reasons PHP is popular:



PHP can be compiled and run on Microsoft Windows, Linux, BSD, Macintosh OS X, and UNIX servers.



PHP can be tightly integrated with most popular WEB servers, including Apache and Microsoft IIS, or as a stand-alone CGI interpreter.



PHP's source code is freely available, and you are free to write and distribute PHP applications for commercial and non-commercial use.



The open source community actively supports development around the PHP language and has made an enthusiastic contribution in this regard. As a result of their efforts, the PHP language provides an impressive set of extensions to provide a variety of features, from XML transformations, dynamically generated images, and Adobe Portable Document formats (Portable document Format,pdf) files to support SOAP clients and servers.



After a brief introduction to PHP scripting, this article describes how to compile PHP into a dynamically loaded Apache module that supports DB2 clients. The end of the article is a few examples that demonstrate how to use PHP to connect to IBM Cloudscape or IBM DB2 Universal database servers, how to insert data into those servers, and how to select data from them. This article updated my previous article to introduce major versioning improvements in all aspects of the stack: from PHP 4 to PHP 5, from Apache 1.3.x to 2.0.x, from DB2 UDB version 7 to version 8, and from the 2.4 kernel to the 2.6 Linux release version of the kernel.



How PHP Scripting Works



PHP is basically a server-side scripting language that allows you to embed application logic into HTML pages, or create an entire HTML page with PHP functions. When a WEB server receives a request for a PHP page, it turns control over to the PHP engine. The PHP engine loads the PHP page, executes all the PHP functions on the page, and then returns the generated HTML to the WEB server.



To invoke a PHP function within a Web page, simply embed the PHP function inside the regular HTML source code. PHP functions are embedded into PHP to start with. The end of the HTML style within the label. For example, <?php echo ' hello! '; ?> demonstrates a call to the PHP function Echo (). To include multiple functions within this PHP tag, you can separate these functions by using the semicolon (;) character.



Of course, you can include many PHP tags in a php script. To demonstrate how easy it is to write a Web page using PHP, here's a short script that outputs a series of numbers starting from any value to the end of any value.



Listing 1. Print sequence functions: print.php


<?php function print_sequence ($start, $stop, $increment) {
 if ($start > $stop) {
  return(FALSE);
 }
 elseif ($increment <= 0) {
  return (FALSE);
 }
 else {
  for ($i = $start; $i < $stop; $i = $i + $increment) {
   print "$i ";
  }
 }
 return(TRUE);
}
?>
 <title>Counting from x to y</title>
<p>Counting from 1 to 10 by 1: <? php print_sequence(1, 10, 1)?></p>
<p>Counting from 2 to 20 by 2: <? php print_sequence(2, 20, 2)?></p>
</body>





Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.