Go to the documentation of this file.00001 <?php
00002
00008
00009
00010 if (!class_exists('DB')) {
00011 include_once('DB.php');
00012 }
00013
00024 class PGTStorageDB extends PGTStorage
00025 {
00038 var $_url='';
00039
00047 function getURL()
00048 {
00049 return $this->_url;
00050 }
00051
00059 var $_link = null;
00060
00069 function getLink()
00070 {
00071 return $this->_link;
00072 }
00073
00081 var $_table = '';
00082
00090 function getTable()
00091 {
00092 return $this->_table;
00093 }
00094
00095
00096
00097
00098
00106 function getStorageType()
00107 {
00108 return "database";
00109 }
00110
00117 function getStorageInfo()
00118 {
00119 return 'url=`'.$this->getURL().'\', table=`'.$this->getTable().'\'';
00120 }
00121
00122
00123
00124
00125
00140 function PGTStorageDB($cas_parent,$user,$password,$database_type,$hostname,$port,$database,$table)
00141 {
00142 phpCAS::traceBegin();
00143
00144
00145 $this->PGTStorage($cas_parent);
00146
00147 if ( empty($database_type) ) $database_type = CAS_PGT_STORAGE_DB_DEFAULT_DATABASE_TYPE;
00148 if ( empty($hostname) ) $hostname = CAS_PGT_STORAGE_DB_DEFAULT_HOSTNAME;
00149 if ( $port==0 ) $port = CAS_PGT_STORAGE_DB_DEFAULT_PORT;
00150 if ( empty($database) ) $database = CAS_PGT_STORAGE_DB_DEFAULT_DATABASE;
00151 if ( empty($table) ) $table = CAS_PGT_STORAGE_DB_DEFAULT_TABLE;
00152
00153
00154 $this->_url = $database_type.':'.'//'.$user.':'.$password.'@'.$server.':'.$port.'/'.$database;
00155
00156
00157 phpCAS::traceEnd();
00158 }
00159
00160
00161
00162
00163
00169 function init()
00170 {
00171 phpCAS::traceBegin();
00172
00173 if ( $this->isInitialized() )
00174 return;
00175
00176 parent::init();
00177
00178
00179 $this->_link = DB::connect($this->getURL());
00180 if ( DB::isError($this->_link) ) {
00181 phpCAS::error('could not connect to database ('.DB::errorMessage($this->_link).')');
00182 }
00183 var_dump($this->_link);
00184 phpCAS::traceBEnd();
00185 }
00186
00188 }
00189
00190 ?>