<?php
/*
=============================================================================================================================================
| This file is part of a project released under the terms of the Xyndravandria PHP License (XyndravandriaPHPLicense.txt). |
| |
| You should be given a copy of the Xyndravandria PHP License (XyndravandriaPHPLicense.txt) within the same directory as the README.md; |
| if not, you can get a copy at http://Xyndravandria.ohost.de/XyndravandriaPHPLicense.txt . |
| |
| The copyright (c) of this project is owned by Mauro Di Girolamo <maurodigirolamo@.web.de>. |
============================================================================================================================================|
Xyndravandria Dyverath
----------------------
Alpha 0.0.0
Xyndravandria is the name of a collection of projects designed and developed by Mauro Di Girolamo (maurodigirolamo@web.de); he is therefore the copyright (c) owner of Xyndravandria itself and all of its projects.
Xyndravandria Dyverath is released under the terms of the Xyndravandria PHP License (XyndravandriaPHPLicense.txt). You should be given a copy of the Xyndravandria PHP License (XyndravandriaPHPLicense.txt) within the same directory as the README.md; if not, you can get a copy at http://Xyndravandria.ohost.de/XyndravandriaPHPLicense.txt . There might be a release under a freer license for a later, more stable version.
The documentation is either included in ./admin_media/Documentation/ or can be read at http://Xyndravandria.ohost.de/Dyverath/Documentation/.
All projects:
Xyndravandria Averazain
http://github.com/MauroDiGirolamo/Xyndravandria_Averazain
PHP
Averazain is an Ajax framework supporting also JavaScript disabled clients perfectly - including search engines like Google.
Xyndravandria Dyverath
http://github.com/MauroDiGirolamo/Xyndravandria_Dyverath
PHP
Dyverath is a database access wrapper.
Xyndravandria Erozaver
http://github.com/MauroDiGirolamo/Xyndravandria_Erozaver
PHP
Erozaver is a class extending the type hinting given by the PHP engine (additional support for basic type hinting and size constraints).
Xyndravandria Mondraviel
http://github.com/MauroDiGirolamo/Xyndravandria_Mondraviel
PHP
Mondraviel is a class used to separate HTML from PHP code by firstly register models - files containing place holders embedded in HTML code - and then later fill them dynamically with content by passing values for the place holders.
*/
namespace Xyndravandria\Dyverath;
use Xyndravandria\Dyverath\Server;
// TODO: GROUP BY.
// TODO: Thing about enabling settype( ) again.
// TODO: Disable caching an test the Current( ) methods.
/// @ref Dyverath "Dyverath's" main class.
/// @abstract
abstract class Dyverath {
/// Used to select MySQL as the database system type.
const Type_MySQL = 1;
/// Opens a connection to a new Server and returns it.
/// @public
/// @static
/// @param string $Host: The MySQL server.
/// @param string $User: The user name.
/// @param string $Password: The password.
/// @param integer $Type: The database system type.
/// @param string $UniqueName: The unique name of the
/// server.
/// @returns Server
/// @note $Type is an optional parameter.
/// Dyverath::Type_MySQL is its value. @n
/// Also, $UniqueName is an optional parameter and
/// should only be passed if you have two @ref Server
/// "Servers" on the same host, since the host is used
/// as the unique name of a Server by default.
public static function Connect( $Host, $User, $Password, $Type = self::Type_MySQL, $UniqueName = '' ) {
//\settype( $Host, 'string' );
//\settype( $User, 'string' );
//\settype( $Password, 'string' );
//\settype( $Type, 'integer' );
//\settype( $UniqueName, 'string' );
$UniqueName == '' && $UniqueName = $Host;
if( $Type != self::Type_MySQL )
throw new XyndravandriaDyverathException( 'Only MySQL is currently supported.' );
else if( self::Server( $UniqueName ) != null )
throw new XyndravandriaDyverathException( 'Given unique name \'' . $UniqueName . '\' already exists.' );
else if( ! ( $Connection = \mysql_connect( $Host, $User, $Password ) ) )
throw new XyndravandriaDyverathException( 'Could not connect to MySQL server: ' . \mysql_error( ) );
else {
$Server = new Server( $UniqueName, $Connection );
if( Server::Configuration( ) & Server::CacheEnabled && ! Server::Cache( )->Get( $Server->UniqueIdentifier( ) ) )
return Server::Cache( )->Add( $Server );
else
return $Server;
}
return;
}
/// Gets a Server from the Cache by its unique name.
/// @public
/// @static
/// @param string $UniqueName: The unique name of the
/// Server.
/// @returns Server or null
/// @note A @ref Server "Server's" host is used as its
/// unique name by default.
public static function Server( $UniqueName ) {
//\settype( $UniqueName, 'string' );
return Server::Cache( )->Get( $UniqueName );
}
}
?>
|