Location: PHPKode > scripts > phpFlickrSynch > phpflickrsynch/_classes/class_TableFlickrGroup.php
<?php
	/**
	  * Access layer to the "flickr_group" table, which contains the list of groups of photo albums
	  */
	class TableFlickrGroup {
		
		public function getGroupName($groupId) {
			global $FLDB;
			$st = $FLDB->prepare('SELECT grp_name name FROM flickr_group WHERE grp_id = ?');
			$st->bindParam(1, $groupId, PDO::PARAM_INT);
			$tab = Helpers::fetchOneRow($st);
			return ($tab == NULL || $tab == false) ? NULL : $tab['name'];
		}		
		
		public function getGroupId($groupName) {
			global $FLDB;
			$st = $FLDB->prepare('SELECT grp_id id FROM flickr_group WHERE grp_name = ?');
			$st->bindParam(1, $groupName, PDO::PARAM_STR);
			$tab = Helpers::fetchOneRow($st);
			return ($tab == NULL || $tab == false) ? 0 : $tab['id'];
		}
		
		public function getAllGroups() {
			return Helpers::execute('SELECT grp_id id, grp_name name FROM flickr_group ORDER BY grp_name');			 
		}
		
		public function createGroup($groupname) {
			global $FLDB;
			$st = $FLDB->prepare('INSERT INTO flickr_group (grp_name) VALUES (?)');
			$st->bindParam(1, $groupname, PDO::PARAM_STR);
			return Helpers::executeInsertStatement($FLDB, $st);
		}
		
		public function updateGroup($id, $groupname) {
			global $FLDB;
			$st = $FLDB->prepare('UPDATE flickr_group SET grp_name=? WHERE grp_id=?');
			$st->bindParam(1, $groupname, PDO::PARAM_STR);			
			$st->bindParam(2, $id, PDO::PARAM_INT);
			return Helpers::executeStatement($st);
		}
		
		public function deleteGroup($id) {
			global $FLDB;
			$st = $FLDB->prepare('UPDATE flickr_portfolio SET grp_id=0 WHERE grp_id=?');
			$st->bindParam(1, $id, PDO::PARAM_INT);
			if (Helpers::executeStatement($st)) {
				$st = $FLDB->prepare('DELETE FROM flickr_group WHERE grp_id=?');
				$st->bindParam(1, $id, PDO::PARAM_INT);
				return Helpers::executeStatement($st);
			} else return false;
		}
	}
?>
Return current item: phpFlickrSynch