Location: PHPKode > projects > JACR - Just Another Checkbook Register > jacr_0.0.4/jacr-platform/tagged_items.class.php
<?php
require_once('DBConn/table.class.php');

class Tagged_items extends DBTable{
	var $taggedStr,$tagID, $itemID;
	public function __construct ($taggedStr,$tagID, $itemID){
		global $dbname, $dbTablPre;
		if ( !isset($taggedStr) )
			throw new Exception("taggedStr: $taggedStr is invalided or not set!");
		if ( !isset($tagID) )
			throw new Exception("tagID: $tagID is invalided or not set!");
		if ( !isset($itemID) )
			throw new Exception("itemID: $itemID is invalided or not set!");
		$this->taggedStr = $taggedStr;
		$this->tagID = $tagID;
		$this->itemID = $itemID;
		
		//$this->taggedStr = $taggedStr;
		$this->tablename       =  $dbTablPre.'tagged_'.$taggedStr;
		$this->dbname          = $dbname;
		$this->rows_per_page   = 0;
		
		$this->fieldlist = array(
						   'tag_id' =>		array('int(11)', 'NOT NULL', NULL, NULL),
						   'item_id' =>	array('int(11)', 'NOT NULL', NULL, NULL)
						   );
		$this->pKEY='item_id';
		//$this->uniqueKEY = Array('tag');
	}
	public function tagItem()
	{
		if(!$this->alreadyTagged())
			$this->insertRecord(Array('tag_id'=> $this->tagID, 'item_id' => $this->itemID));
	}
	public function alreadyTagged()
	{
		return ( is_array( $this->getData('tag_id='. $this->tagID .' AND item_id ='.$this->itemID) ) );
	}
	public function deleteTags()
	{
		$this->execute('DELETE FROM ' .$this->table. ' WHERE tag_id='. $this->tagID .' AND item_id ='.$this->itemID);
	}
	public function showTags()
	{
		
	}
	#returns an array $tag => $tagID for on an item
	public function getTags()
	{
	}
	
	public function getTagsIds()
	{
		$tagArray = $this->getData('item_id ='.$this->itemID);
		$tags = NULL;
		$i = 0;
		foreach ($tagArray as $tagId){
			$tags[$i] = $tagId['tag_id'];
			$i++;
		}
			
		return ($tags);
	}
}
?>
Return current item: JACR - Just Another Checkbook Register