databases
[
class tree: databases
] [
index: databases
] [
all elements
]
changelog
install
readme
Todo List
Packages:
core
communication
databases
data_structures
filesystem
forms
GilliGan
html
Services_JSON
Source for file ABSTDatabaseHost.class.php
Documentation is available at
ABSTDatabaseHost.class.php
<?php
/**
* For including this file you have to define the constant "CLASSPATH".
* Because every include in the framework depends on the CLASSPATH definition.
* The CLASSPATH means the relative path to the folder that contains the
* framework GilliGan.
*
*
@package
databases
*/
if
(
!
defined
(
"CLASSPATH"
) )
{
echo
"<h3>You have to define the constant CLASSPATH!</h3>\r\n"
;
echo
"Example: define( 'CLASSPATH', '../path/to/classes/' );\r\n"
;
exit
(
)
;
}
/**
*
*/
require_once
(
CLASSPATH
.
"settings.inc.php"
)
;
/**
*
*/
require_once
(
CLASSPATH
.
"DebuggingSettings.inc.php"
)
;
/**
*
@abstract
*
@package
databases
*
@version
0.1.44
*
@author
Daniel Plücken <daniel@debakel.net>
*
@license
http://www.gnu.org/copyleft/lesser.html
* GNU Lesser General Public License
*
@copyright
Copyright (C) 2004 Daniel Plücken <daniel@debakel.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA
*/
class
ABSTDatabaseHost
{
/**
* The Name of the databasehost.
*
*
@var
string
$name
*
@access
public
*/
var
$name
;
/**
* The connection's port.
*
*
@var
int
$port
*
@access
public
*/
var
$port
;
/**
* The username to log on the database server.
*
*
@var
string
$user
*
@access
public
*/
var
$user
;
/**
* The password to log on the database server.
*
*
@var
string
$password
*
@access
public
*/
var
$password
;
/**
* Carries the references to objects of databases.
*
*
@var
array
$db
*
@access
private
*/
var
$db
;
/**
*
@var
object
$resID
*
@access
public
*/
var
$resID
;
/**
* The connection's state of the databasehost.
*
*
@var
boolean
$is_connected
*
@access
private
*/
var
$is_connected
=
false
;
/**
* Carries the name of a function which has to be invoked on a connection
* error.
*
*
@access
public
*
@var
function
$error_callback
*/
var
$error_callback
=
null
;
/**
* Fake-Constructor
*
*
@version
1.0
*
@since
0.1.3
*
@author
Daniel Plücken <daniel@debakel.net>
*
@access
public
*/
function
ABSTDatabaseHost
(
)
{
echo
"<h3>This is an abstract class. "
.
"You cannot get an instance of it!</h3>"
;
exit
(
)
;
}
/**
* Constructor.
* All parameter are optional.
*
*
@version
1.0
*
@since
0.1.3
*
@author
Daniel Plücken <daniel@debakel.net>
*
@access
public
*
@param
string
$host
The host on which the database server runs.
*
@param
string
$user
The user to log on the database host.
*
@param
string
$password
The password to log on the database host.
*
@param
string
$port
The port on which should be the communication.
*/
function
__constructor
(
$host
=
"localhost"
,
$user
=
""
,
$password
=
""
,
$port
=
""
)
{
$this
->
name
=
$host
;
$this
->
user
=
$user
;
$this
->
password
=
$password
;
$this
->
port
=
$port
;
}
/**
* Sets the name of the function that should be invoked on a connection error.
* The function to call back has to have two parameter. The first parameter is
* for the error code. The second one contains the errordescription.
*
*
@version
1.0
*
@since
0.1.43
*
@author
Daniel Plücken <daniel@debakel.net>
*
@access
public
*
@param
string
$function_name_str
*
@return
void
*/
function
setConnectionErrorCallback
(
$function_name_str
)
{
$this
->
error_callback
=
$function_name_str
;
}
/**
* Sets the hostname.
*
*
@version
1.0
*
@since
0.1.0
*
@author
Daniel Plücken <daniel@debakel.net>
*
@access
public
*
@param
string
*
@return
void
*/
function
setHost
(
$string
)
{
$this
->
name
=
$string
;
}
/**
* Sets the hostname. This method is an alias of the method setHost( $string ).
*
*
@version
1.0
*
@since
0.1.0
*
@author
Daniel Plücken <daniel@debakel.net>
*
@access
public
*
@param
string
$string
*
@return
void
*/
function
setName
(
$string
)
{
$this
->
name
=
$string
;
}
/**
* Specifies the port that should be used to connect to the host.
*
*
@version
1.0
*
@since
0.1.0
*
@author
Daniel Plücken <daniel@debakel.net>
*
@access
public
*
@param
int
$int
*
@return
void
*/
function
setPort
(
$int
)
{
$this
->
port
=
$int
;
}
/**
* Specifies the user who should connect with to the host.
*
*
@version
1.0
*
@since
0.1.0
*
@author
Daniel Plücken <daniel@debakel.net>
*
@access
public
*
@param
string
$string
*
@return
void
*/
function
setUser
(
$string
)
{
$this
->
user
=
$string
;
}
/**
* Sets the password that should be used to connect to the host.
*
*
@version
1.0
*
@since
0.1.0
*
@author
Daniel Plücken <daniel@debakel.net>
*
@access
public
*
@param
string
$string
*
@return
void
*/
function
setPassword
(
$string
)
{
$this
->
password
=
$string
;
}
/**
* Adds a database's reference to this object of a database host.
*
*
@version
1.1
*
@since
0.1.0
*
@author
Daniel Plücken <daniel@debakel.net>
*
@access
public
*
@param
object
$dbt_obj
*
@return
void
*/
function
addDB
(
&
$db_obj
)
{
if
(
!
function_exists
(
"is_a"
)
&&
(
get_class
(
$db_obj
)
==
"database"
||
get_parent_class
(
$db_obj
)
==
"database"
)
)
{
$db_obj
->
setParent
(
$this
)
;
$this
->
db
[
]
=
&
$db_obj
;
}
else
if
(
function_exists
(
"is_a"
)
&&
(
is_a
(
$db_obj
,
"Database"
)
||
is_subclass_of
(
$db_obj
,
"database"
)
)
)
{
$db_obj
->
setParent
(
$this
)
;
$this
->
db
[
]
=
&
$db_obj
;
}
else
die
(
"<h3>The parameter does not refer to "
.
"a valid object of a database!</h3>"
)
;
}
/**
* Returns the hostname.
*
*
@version
1.0
*
@since
0.1.0
*
@author
Daniel Plücken <daniel@debakel.net>
*
@access
public
*
@return
string
*/
function
getHost
(
)
{
return
$this
->
name
;
}
/**
* Returns the hostname. This method is an alias of the method getHost().
*
*
@version
1.0
*
@since
0.1.0
*
@author
Daniel Plücken <daniel@debakel.net>
*
@access
public
*
@return
string
*/
function
getName
(
)
{
return
$this
->
name
;
}
/**
* Returns the specified port to use to connect to the host.
*
*
@version
1.0
*
@since
0.1.0
*
@author
Daniel Plücken <daniel@debakel.net>
*
@access
public
*
@return
int
*/
function
getPort
(
)
{
return
$this
->
port
;
}
/**
* Returns the specified user who should connect with to the host.
*
*
@version
1.0
*
@since
0.1.0
*
@author
Daniel Plücken <daniel@debakel.net>
*
@access
public
*
@return
string
*/
function
getUser
(
)
{
return
$this
->
user
;
}
/**
* Returns the given password which should be usedto connect to the host.
*
*
@access
public
*
@version
1.0
*
@since
0.1.0
*
*
@return
string
*/
function
getPassword
(
)
{
return
$this
->
password
;
}
/**
* Returns the id of the connection resource to the database host.
*
*
@access
public
*
@version
1.0
*
@since
0.1.44
*
*
@return
object
*/
function
&
getResourceID
(
)
{
return
$this
->
resID
;
}
}
// End of class ABSTDatabaseHost
?>
Documentation generated on Thu, 05 Jun 2008 19:09:38 +0200 by
phpDocumentor 1.4.1