Ejemplo n.º 1
0
		/**
		 *	setAdapterType
		 *
		 *	Static mutator that sets the adapter type. Logically called before composition.
		 *		 
		 *	@static
		 *	@final
		 *	@access	public
		 *	@params	Mixed		The type of database adapter to be created.
		 */
		public static final function setAdapterType( $adapter = NULL )
		{
			
			if( NULL == $adapter ) {				
				require_once( 'Yeba' . DIRECTORY_SEPARATOR . 'Database' . DIRECTORY_SEPARATOR . 'Exception.class.php' );
				throw new Yeba_Database_Exception( Yeba_Database_Exception::EMPTY_ADAPTER_TYPE );
			}
			
			if( self::isValidAdapter( $adapter ) ) {			
				self::$_adapterType = $adapter;
			} else {
				require_once( 'Yeba' . DIRECTORY_SEPARATOR . 'Database' . DIRECTORY_SEPARATOR . 'Exception.class.php' );
				throw new Yeba_Database_Exception( Yeba_Database_Exception::INVALID_ADAPTER_TYPE );
			}			
			
		} // end static member setAdapterType
Ejemplo n.º 2
0
		Yeba_Database_Composer::setAdapterType( Yeba_Database_Composer::DB_MYSQL );	
		$testResult['MySQL']['setAdapterType'] = 'Adapter type set to MySQL.';
		try {
			Yeba_Database_Composer::compose();
			$testResult['MySQL']['composeWithoutParameter'] = 'Yeba_Database_Compose triggered without parameters.';
			try {
				$type = Yeba_Database_Composer::getAdapterType();
				$testResult['MySQL']['getAdapterType'] = 'Type provided is ' . $type;
			} catch( Exception $exception ) {
				echo $exception->getMessage(), '<br />';
			}		
		} catch( Exception $exception ) {
			echo $exception->getMessage(), '<br />';
		}		
		try {
			$type = Yeba_Database_Composer::compose( Yeba_Database_Composer::DB_MSSQL );
			$testResult['MySQL']['composeWithParameter'] = 'Yeba_Database_Compose triggered with parameter( MsSQL type )';
			try {
				$type = Yeba_Database_Composer::getAdapterType();
				$testResult['MySQL']['getAdapterTypeAfterCompose'] = 'Type provided is ' . $type;
			} catch( Exception $exception ) {
				echo $exception->getMessage(), '<br />';
			}		
		} catch( Exception $exception ) {
			echo $exception->getMessage(), '<br />';
		}		
	} catch( Exception $exception ) {
		echo $exception->getMessage(), '<br />';
	}		
	 
	require_once( 'views' . DIRECTORY_SEPARATOR . 'Database' . DIRECTORY_SEPARATOR . 'Main.template.yhtml' );