ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
pgt-db.php
Go to the documentation of this file.
1 <?php
2 
8 // include phpDB library (the test was introduced in release 0.4.8 for
9 // the integration into Tikiwiki).
10 if (!class_exists('DB')) {
11  include_once('DB.php');
12 }
13 
24 class PGTStorageDB extends PGTStorage
25 {
38  var $_url='';
39 
47  function getURL()
48  {
49  return $this->_url;
50  }
51 
59  var $_link = null;
60 
69  function getLink()
70  {
71  return $this->_link;
72  }
73 
81  var $_table = '';
82 
90  function getTable()
91  {
92  return $this->_table;
93  }
94 
95  // ########################################################################
96  // DEBUGGING
97  // ########################################################################
98 
106  function getStorageType()
107  {
108  return "database";
109  }
110 
117  function getStorageInfo()
118  {
119  return 'url=`'.$this->getURL().'\', table=`'.$this->getTable().'\'';
120  }
121 
122  // ########################################################################
123  // CONSTRUCTOR
124  // ########################################################################
125 
140  function PGTStorageDB($cas_parent,$user,$password,$database_type,$hostname,$port,$database,$table)
141  {
143 
144  // call the ancestor's constructor
145  $this->PGTStorage($cas_parent);
146 
147  if ( empty($database_type) ) $database_type = CAS_PGT_STORAGE_DB_DEFAULT_DATABASE_TYPE;
148  if ( empty($hostname) ) $hostname = CAS_PGT_STORAGE_DB_DEFAULT_HOSTNAME;
149  if ( $port==0 ) $port = CAS_PGT_STORAGE_DB_DEFAULT_PORT;
150  if ( empty($database) ) $database = CAS_PGT_STORAGE_DB_DEFAULT_DATABASE;
151  if ( empty($table) ) $table = CAS_PGT_STORAGE_DB_DEFAULT_TABLE;
152 
153  // build and store the PEAR DB URL
154  $this->_url = $database_type.':'.'//'.$user.':'.$password.'@'.$server.':'.$port.'/'.$database;
155 
156  // XXX should use setURL and setTable
158  }
159 
160  // ########################################################################
161  // INITIALIZATION
162  // ########################################################################
163 
169  function init()
170  {
172  // if the storage has already been initialized, return immediatly
173  if ( $this->isInitialized() )
174  return;
175  // call the ancestor's method (mark as initialized)
176  parent::init();
177 
178  // try to connect to the database
179  $this->_link = DB::connect($this->getURL());
180  if ( DB::isError($this->_link) ) {
181  phpCAS::error('could not connect to database ('.DB::errorMessage($this->_link).')');
182  }
183  var_dump($this->_link);
184  phpCAS::traceBEnd();
185  }
186 
188 }
189 
190 ?>
$_url
a string representing a PEAR DB URL to connect to the database.
Definition: pgt-db.php:60
init()
This method is used to initialize the storage.
Definition: pgt-db.php:169
The PGTStorageDB class is a class for PGT database storage.
Definition: pgt-db.php:46
getURL()
This method returns the PEAR DB URL to use to connect to the database.
Definition: pgt-db.php:69
traceEnd($res='')
This method is used to indicate the end of the execution of a function in debug mode.
Definition: CAS.php:604
$_table
The name of the table where PGT&#39;s are stored.
Definition: pgt-db.php:103
const CAS_PGT_STORAGE_DB_DEFAULT_HOSTNAME
default host when storing PGT&#39;s to database
Definition: CAS.php:172
PGTStorageDB($cas_parent, $user, $password, $database_type, $hostname, $port, $database, $table)
The class constructor, called by CASClient::SetPGTStorageDB().
Definition: pgt-db.php:140
const CAS_PGT_STORAGE_DB_DEFAULT_DATABASE
default database when storing PGT&#39;s to database
Definition: CAS.php:180
PGTStorage($cas_parent)
The constructor of the class, should be called only by inherited classes.
Definition: pgt-main.php:63
getTable()
This method returns the name of the table where PGT&#39;s are stored.
Definition: pgt-db.php:90
getStorageType()
This method returns an informational string giving the type of storage used by the object (used for d...
Definition: pgt-db.php:106
$_link
The handle of the connection to the database where PGT&#39;s are stored.
Definition: pgt-db.php:81
traceBegin()
This method is used to indicate the start of the execution of a function in debug mode...
Definition: CAS.php:577
getLink()
This method returns the handle of the connection to the database where PGT&#39;s are stored.
Definition: pgt-db.php:69
error($msg)
This method is used by interface methods to print an error and where the function was originally call...
Definition: CAS.php:544
getURL()
This method returns the PEAR DB URL to use to connect to the database.
Definition: pgt-db.php:47
$server
getStorageInfo()
This method returns an informational string giving informations on the parameters of the storage...
Definition: pgt-db.php:117
const CAS_PGT_STORAGE_DB_DEFAULT_TABLE
default table when storing PGT&#39;s to database
Definition: CAS.php:184
const CAS_PGT_STORAGE_DB_DEFAULT_PORT
default port when storing PGT&#39;s to database
Definition: CAS.php:176
isInitialized()
This method tells if the storage has already been intialized.
Definition: pgt-main.php:160
The PGTStorage class is a generic class for PGT storage.
Definition: pgt-main.php:45
const CAS_PGT_STORAGE_DB_DEFAULT_DATABASE_TYPE
default database type when storing PGT&#39;s to database
Definition: CAS.php:168