professional-php-01-class.Widget.php / php
<?php class Widget { private name; private hDB; private widgetID) { //The widgetID parameter is the primary key of a //record in the database containing the information //for this object //Create a connection handle and store it in a private member variable this->hDB)) { throw new Exception('Unable to connect to the database.'); } widgetID"; this->hDB, rs)) { throw new Exception("An error occurred selecting from the database."); } if(! pg_num_rows(data = pg_fetch_array(this->id = this->name = this->description = this->name; } public function getDescription() { return name) { name; description) { description; this->needsUpdating) { return; } sql .= "\"name\" = '" . pg_escape_string(sql .= "\"description\" = '" . pg_escape_string(sql .= "WHERE widgetID = " . rs = pg_query(sql); if(! is_resource(//You're done with the database. Close the connection handle. pg_close(this->hDB); } } ?>
(C) Æliens 20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.