678Part IVConnectionsThe program sends the query to the (Web server type)

678Part IVConnectionsThe program sends the query to the database and checks to see if an error message comesback. $returnArray = array(); while ($row = $result->fetchRow()) { $id = $row[0]; $desc = $row[1]; $weight = $row[2]; $packageQty = $row[3]; $unit = $row[4]; $supplierID = $row[5]; $cost= $row[6]; $returnArray[] = array( id => $id, desc => $ desc, weight => $weight, packageQty => $packageQty, unit => $unit, supplierID => $ supplierID, cost => $cost); } $db->disconnect(); return $returnArray; ?> The remainder of the program involves setting up an array called $returnArray. It is filledwith a series of subarrays, making it a two-dimensional array. The subarrays are associativearrays; their keys correspond to column names in the database, and their values come fromeach row of $result. PEAR DB FunctionsThe PEAR DB class is fairly extensive, with members far more numerous than the widely usedones covered already in this chapter s examples. Most of the other members are specialized, and as such come in handy only under particular circumstances. This section summarizes some of the most useful members of the PEAR DB class, but is notcomprehensive. Be sure to refer to http://pear.php.net/manual/en/package.database. phpfor the official list and documentation. Members of the DB classThe DBclass itself is the main PEAR DB class, and is used to represent a connection to adatabase (or an attempt to create one). Methods include: .DB::connect(): Uses a DSN to connect to a database. .DB::isWarning(): Returns true if a connection attempt yielded a warning. .DB::isError(): Returns true if a connection attempt yielded an error. Members of the DB_Common classThe methods of the DB_Commonclass may be invoked on a database connection for such pur- poses as executing queries and getting information from the database. Methods include:
We would like to recommend you tested and proved virtual web hosting services, which you will surely find to be of great quality.

Leave a Reply