All pastes #1288897 Raw Edit

Unnamed

public php v1 · immutable
#1288897 ·published 2008-12-18 23:52 UTC
rendered paste body
<?phpclass Categorymodel extends Model {	var $id = 0;	function Categorymodel()	{		parent::Model();	}		/**	*  Save new category into database	*/	function save( $category )	{			if( !is_array($category) )			return;				//check if we have a parent		if( sizeof( $category ) > 2 )		{			if( $this->byID( $category['parent'] ) == false )			{				$category['parent'] = 0;			}		}				//lets check if its a child or not		if( $category['child'] == 0 )		{			$category['parent'] = 0;		}				//save the data		$this->db->insert("category",$category);	}	/**	*  Category By ID	*	*  Gets category from database, returns true if category exists	*  return boolean	*/	function byID( $id )	{		$query = $this->db->get_where("category",array('id' => $id));		if( $query->num_rows() == 0 ) 			return false;		return true;	}}/* END OF FILE */