Post by Kristal Rose Phoenix McKinstry on Oct 27, 2005 4:57:46 GMT -5
<?php
#fd
##########################################################################################
######################### SMC CS85 CHESS PROGRAM #########################################
##########################################################################################
if ($ulShowVersions) print('
#### oServer.rpq #########################################################################<br />
#### 2005.10.26 22:40 - km modified to support new oServer object ! ! ###############<br />');
##########################################################################################
##########################################################################################
#### Status: !! LOCKED !! by KM ##########################################################
#### !! FINISHED !! ##########################################################
##########################################################################################
##########################################################################################
#### Description: ####################################
#### ####################################
#### An oServer object is now required for oStorage or #################
#### anything else which may require sql connections. #################
#### #################
#### It requires sConnect.rsp which contains the following 7 lines: #################
/*
<?php
############ sConnect.rsp ############ See oServer.rpq for documentation.
$lsHostName = 'localhost';
$lsUser = 'SomeUserName';
$lsPassword = 'ThatUsersPassword';
$lsDatabase = 'chess';
?>
*/
#### #################
#### Note that you will need to create your sConnect.rsp file for #################
#### testing at home/school and will need to provide real user names #################
#### and passwords. #################
#### #################
#### Leave an appropriate filled sConnect.rsp on/for each server #################
#### #################
#### #################
#### oServer is instantiated near the beginning of chess.php #################
#### #################
#### Typical method call $loMyServer->fConnect(); #################
#### #################
#### USAGE: Hand an instance of oServer to any functions requiring #################
#### SQL connections, then call oServer->fSelectDB(). #################
#### or oServer->fSelectDB('alternateDatabaseThanSConnectDefault'). #################
#### In objects which require sql connections, pass an oServer #################
#### by reference through the default constructor method #################
#### (function with same name as class) then call in other methods #################
#### like this: $this->voServer->fSelectDB(); #################
#### #################
#### Note: Originally I was thinking to have a #################
#### fSetServer('Local'/'Remote') method. #################
#### #################
##########################################################################################
#### Programmer: Kristal McKinstry ######################################################
##########################################################################################
##########################################################################################
/*
$linkLocal = mysql_connect('localhost', 'chreq', 'castle'); // possible production call.
$linkRemote = mysql_connect('localhost', 'root', 'clouds63') or die('Could not connect: ' . mysql_error()); //// See 'testing' folder for production version.
$lsDatabaseLocal = 'chess';
$lsDatabaseRemote = 'ereiamco_chess';
*/
class oServer {
var $vlsHostName;// = 'localhost'
var $vlsUser;// = 'SomeUserName'
var $vlsPassword;// = 'ThatUsersPassword'
var $vlsDatabase;// = 'chess'
var $vlmResource = 'zilch'; // Supplied by fConnect
//function oServer($lsHostName, $lsUser, $lsPassword, $lsDatabase){
function oServer(){
require('sConnect.rsp');
$this->vlsHostName = $lsHostName; //'localhost';
$this->vlsUser = $lsUser; //'SomeUserName';
$this->vlsPassword = $lsPassword; //'ThatUsersPassword'
$this->vlsDatabase = $lsDatabase; //'chess'
} //end-func oServer
function fConnect(){
$link = mysql_connect($this->vlsHostName, $this->vlsUser, $this->vlsPassword) or die('Could not connect: ' . mysql_error()); //// See 'testing' folder for production version. ####!!!!
$this->vlmResource = $link;
return($link);
}//end-func fConnect
function fSelectDB($lsDatabase = 'zilch'){ //selects database and returns link for future activities which need connection resource.
if ($this->vlmResource != 'zilch') $link = $this->vlmResource;
else $link = $this->fConnect();
if ($lsDatabase == 'zilch') $lsDatabase = $this->vlsDatabase; //else $lsDatabase = $lsDatabase;
$llSelected = mysql_select_db($lsDatabase, $link);
return($llSelected);
}//end-func fSelectDB
}//end-class oServer
?>
#fd
##########################################################################################
######################### SMC CS85 CHESS PROGRAM #########################################
##########################################################################################
if ($ulShowVersions) print('
#### oServer.rpq #########################################################################<br />
#### 2005.10.26 22:40 - km modified to support new oServer object ! ! ###############<br />');
##########################################################################################
##########################################################################################
#### Status: !! LOCKED !! by KM ##########################################################
#### !! FINISHED !! ##########################################################
##########################################################################################
##########################################################################################
#### Description: ####################################
#### ####################################
#### An oServer object is now required for oStorage or #################
#### anything else which may require sql connections. #################
#### #################
#### It requires sConnect.rsp which contains the following 7 lines: #################
/*
<?php
############ sConnect.rsp ############ See oServer.rpq for documentation.
$lsHostName = 'localhost';
$lsUser = 'SomeUserName';
$lsPassword = 'ThatUsersPassword';
$lsDatabase = 'chess';
?>
*/
#### #################
#### Note that you will need to create your sConnect.rsp file for #################
#### testing at home/school and will need to provide real user names #################
#### and passwords. #################
#### #################
#### Leave an appropriate filled sConnect.rsp on/for each server #################
#### #################
#### #################
#### oServer is instantiated near the beginning of chess.php #################
#### #################
#### Typical method call $loMyServer->fConnect(); #################
#### #################
#### USAGE: Hand an instance of oServer to any functions requiring #################
#### SQL connections, then call oServer->fSelectDB(). #################
#### or oServer->fSelectDB('alternateDatabaseThanSConnectDefault'). #################
#### In objects which require sql connections, pass an oServer #################
#### by reference through the default constructor method #################
#### (function with same name as class) then call in other methods #################
#### like this: $this->voServer->fSelectDB(); #################
#### #################
#### Note: Originally I was thinking to have a #################
#### fSetServer('Local'/'Remote') method. #################
#### #################
##########################################################################################
#### Programmer: Kristal McKinstry ######################################################
##########################################################################################
##########################################################################################
/*
$linkLocal = mysql_connect('localhost', 'chreq', 'castle'); // possible production call.
$linkRemote = mysql_connect('localhost', 'root', 'clouds63') or die('Could not connect: ' . mysql_error()); //// See 'testing' folder for production version.
$lsDatabaseLocal = 'chess';
$lsDatabaseRemote = 'ereiamco_chess';
*/
class oServer {
var $vlsHostName;// = 'localhost'
var $vlsUser;// = 'SomeUserName'
var $vlsPassword;// = 'ThatUsersPassword'
var $vlsDatabase;// = 'chess'
var $vlmResource = 'zilch'; // Supplied by fConnect
//function oServer($lsHostName, $lsUser, $lsPassword, $lsDatabase){
function oServer(){
require('sConnect.rsp');
$this->vlsHostName = $lsHostName; //'localhost';
$this->vlsUser = $lsUser; //'SomeUserName';
$this->vlsPassword = $lsPassword; //'ThatUsersPassword'
$this->vlsDatabase = $lsDatabase; //'chess'
} //end-func oServer
function fConnect(){
$link = mysql_connect($this->vlsHostName, $this->vlsUser, $this->vlsPassword) or die('Could not connect: ' . mysql_error()); //// See 'testing' folder for production version. ####!!!!
$this->vlmResource = $link;
return($link);
}//end-func fConnect
function fSelectDB($lsDatabase = 'zilch'){ //selects database and returns link for future activities which need connection resource.
if ($this->vlmResource != 'zilch') $link = $this->vlmResource;
else $link = $this->fConnect();
if ($lsDatabase == 'zilch') $lsDatabase = $this->vlsDatabase; //else $lsDatabase = $lsDatabase;
$llSelected = mysql_select_db($lsDatabase, $link);
return($llSelected);
}//end-func fSelectDB
}//end-class oServer
?>