Location: PHPKode > scripts > DABAJAX Toolkit > dabajax-toolkit/AjaxFormat.class.php
<?php
   /**
     * AjaxFormat - this class has only a method to format values depending on its datatype
     *
     * @author		hide@address.com
     * @package 	easy_ajax
   **/
   class AjaxFormat {
      
      static $NUMERIC     = 0;
      static $ALPHA       = 1;
      static $DATE        = 2;
      static $CONTAINS    = 3;
      static $STARTS_WITH = 4;
      static $ENDS_WITH   = 5;
      
		/**
		 * method to format values for database 
		 * 
		 * @param	string	$value	value to be formatted
		 * @param	integer	$type	   data type ( for dates use DD/MM/YYYY )
		 * @return  string   
		 * @access  private
		*/
		public function formatValue( $value, $type ) {
		
			switch ($type) {
				case self::$NUMERIC:
					$ret = $value;
				   break;
				
				case self::$ALPHA:
					$ret = "'$value'";
				   break;

				case self::$CONTAINS:
					$ret = "'%$value%'";
				   break;

				case self::$STARTS_WITH:
					$ret = "'$value%'";
				   break;

				case self::$ENDS_WITH:
					$ret = "'%$value'";
				   break;
				
				case self::$DATE:
					$date  = explode("/", $value);
					$day   = str_pad($date[0], 2, "0", STR_PAD_LEFT);
					$month = str_pad($date[1], 2, "0", STR_PAD_LEFT);
					$year  = $date[2];
					
					$ret = "'$year-$month-$day'";
				   break;
				
				default:
					$ret = $value;
			}
			return $ret;
		}
   }
?>
Return current item: DABAJAX Toolkit