); 
Processing query
Now the connection to the database is established and this connection can be 
used to execute the query. This can be done by calling the 
ADOConnection
. 
Execute() 
function. The function calls for DB2 UDB and MySQL remains the 
same, so they do not require any changes. Whereas the SQL statements may 
require change due to the SQL difference in MySQL and DB2 UDB. 
  Executing the 
SELECT
 query and fetching results
The query execution and result fetching code remains the same for 
MySQL and DB2 UDB. The Example 7 33 shows the code for query 
execution, and the result fetching using the ADOdb library for PHP.
Example 7 33   Select query execution
$recordSet = $conn >Execute( select * from katalog );
if (!$recordSet) 
print $conn >ErrorMsg();
else{
while (!$recordSet >EOF) {
print  HERSTELLER=  .$recordSet >fields[0].  Model= 
 .$recordSet >fields[1];
$recordSet >MoveNext();
}
$recordSet >Close();
}
$conn >Close();
  Executing 
UPDATE/INSERT
 statement
The code for executing 
UPDATE
 and 
INSERT
 remains the same. The code 
for inserting the data is shown in Example 7 34.
Example 7 34   Executing update/insert statement
$sql = "INSERT INTO katalog (id, model,type) values (1,'1001', new )";
$conn >Execute($sql);
print "Number of rows affected =".$conn >Affected_Rows() ;
$conn.Close();
Converting MySQL PEAR DB PHP applications to DB2 UDB
Another means to provide a database abstraction in the PHP application is using 
the PHP extension and add on repository for the database (PEAR DB). PEAR 
DB is the default database abstraction library included in PHP4. It is quite similar 
to more the popular library ADOdb functionally, but the syntax for both is quite 
different.
 Chapter 7. Application porting 
185






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

san diego web hosting

 

Our partners: PHP: Hypertext Preprocessor Cheap Web Hosting JSP Web Hosting Ontario Web Hosting  Jsp Web Hosting

Cheapest Web Hosting Java Hosting Cheapest Hosting

Visionwebhosting.net Business web hosting division of Vision Web Hosting Inc.. All rights reserved