ZNF
Business
[
class tree: ZNF
] [
index: ZNF
] [
all elements
]
ZNF
Packages:
ZNF
Source for file DB.php
Documentation is available at
DB.php
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* PHP version 5
*
* This source file is subject to version 2.1 of the GNU Lesser General Public
* License, that is bundled with this package in the file COPYING, available
* through the world wide web at the following URI:
* http://www.gnu.org/copyleft/lesser.html.
*
*
@package
ZNF
*
@subpackage
Business
*
@author
Alessandro Rossini <http://www.alessandrorossini.org>
*
@author
Graziano Liberati <http://www.liberati.org>
*
@copyright
2004-2007 The ZNF Development Team
*
@license
LGPL License 2.1 <http://www.gnu.org/copyleft/lesser.html>
*
@version
SVN $Id: DB.php 43 2007-06-26 23:36:35Z aronnax $
*
@since
Release 0.5.0
*
@link
http://www.zeronotice.org
*/
require_once
(
'DB.php'
)
;
require_once
(
'ZNF/Config/DBConfig.php'
)
;
/**
* The <i>ZNF_Business_DB</i> class extends the PEAR <i>DB</i> class.
*
* Connects to the database using the configuration taken from the database
* configuration file. Returns the <i>ZNF_Business_DB</i> object reference with
* a singleton pattern.
*
*
@access
public
*
@package
ZNF
*
@subpackage
Business
*
@author
Alessandro Rossini <http://www.alessandrorossini.org>
*
@author
Graziano Liberati <http://www.liberati.org>
*
@copyright
2004-2007 The ZNF Development Team
*
@license
LGPL License 2.1 <http://www.gnu.org/copyleft/lesser.html>
*
@version
SVN $Id: DB.php 43 2007-06-26 23:36:35Z aronnax $
*
@since
Release 0.5.0
*
@link
http://www.zeronotice.org
*/
class
ZNF_Business_DB
extends
DB
{
/**
* The database object reference.
*
*
@access
private
*
@staticvar
ZNF_Business_DB
$_db
*/
static
private
$_db
;
/**
* Prefix used in the name of the database tables.
*
*
@access
private
*
@staticvar
string
$_tablePrefix
*/
static
private
$_tablePrefix
;
/**
* Private constructor to avoid <i>ZNF_Business_DB</i> object creation.
*
*
@access
private
*/
private
function
__construct
(
)
{
}
/**
* Private clonator to avoid <i>ZNF_Business_DB</i> object clonation.
*
*
@access
private
*/
private
function
__clone
(
)
{
}
/**
* Returns the reference to the <i>ZNF_Business_DB</i> object with a singleton pattern.
*
* This object is shared by all the classes that require the access to the
* database.
*
*
@static
*
@access
public
*
@return
ZNF_Business_DB
*/
static
public
function
getInstance
(
)
{
if
(
!
(
isset
(
self
::
$_db
)))
{
$dbConfig
=
ZNF_Config_DBConfig
::
getInstance
(
)
;
$dsn
=
"
{
$dbConfig
->
getDbms
(
)
}
://{
$dbConfig
->
getUsername
(
)
}
:{
$dbConfig
->
getPassword
(
)
}
@{
$dbConfig
->
getHostname
(
)
}
/{
$dbConfig
->
getDbname
(
)
}
"
;
self
::
$_db
=
self
::
connect
(
$dsn
)
;
if
(
self
::
isError
(
self
::
$_db
))
{
$translation
=
new
ZNF_Presentation_Translation
(
'ZNF'
,
$_SESSION
[
'znf'
]
[
'lang'
]
)
;
throw
new
ZNF_Business_DBException
(
$translation
->
get
(
'errorDbConnection'
))
;
}
else
{
self
::
$_db
->
setFetchMode
(
DB_FETCHMODE_ASSOC
)
;
}
self
::
$_tablePrefix
=
$dbConfig
->
getTablePrefix
(
)
;
}
return
self
::
$_db
;
}
/**
* Returns the prefix used in the name of the database tables.
*
*
@static
*
@access
public
*
@return
string
*/
static
public
function
getTablePrefix
(
)
{
return
self
::
$_tablePrefix
;
}
/**
* Destroys the <i>ZNF_Business_DB</i> object.
*
*
@access
public
*/
public
function
__destruct
(
)
{
}
}
/**
* <i>ZNF_Business_DBException</i> is the exception type for the <i>ZNF_Business_DB</i> class.
*
* <i>ZNF_Business_DBException</i> extends the <i>Exception</i> class of PHP5.
*
*
@access
public
*
@package
ZNF
*
@subpackage
Business
*
@author
Alessandro Rossini <http://www.alessandrorossini.org>
*
@author
Graziano Liberati <http://www.liberati.org>
*
@copyright
2004-2007 The ZNF Development Team
*
@license
LGPL License 2.1 <http://www.gnu.org/copyleft/lesser.html>
*
@version
SVN $Id: DB.php 43 2007-06-26 23:36:35Z aronnax $
*
@since
Release 0.5.0
*
@link
http://www.zeronotice.org
*/
class
ZNF_Business_DBException
extends
Exception
{
}
?>
Documentation generated on Wed, 14 Nov 2007 23:47:35 +0100 by
phpDocumentor 1.4.0