30 define(
'CAS_PGT_STORAGE_DB_DEFAULT_TABLE',
'cas_pgts');
115 return 'table=`' . $this->
_getTable() .
'\'';
144 $driver_options = null
148 parent::__construct($cas_parent);
154 if (!is_array($driver_options)) {
155 $driver_options = array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION);
159 if ($dsn_or_pdo instanceof
PDO) {
160 $this->_pdo = $dsn_or_pdo;
162 $this->_dsn = $dsn_or_pdo;
163 $this->_username = $username;
165 $this->_driver_options = $driver_options;
195 if (!($this->_pdo instanceof
PDO)) {
197 $this->_pdo =
new PDO(
201 $this->_driver_options
204 phpCAS::error(
'Database connection error: ' . $e->getMessage());
230 $this->_errMode =
$pdo->getAttribute(PDO::ATTR_ERRMODE);
231 $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
243 $pdo->setAttribute(PDO::ATTR_ERRMODE, $this->_errMode);
260 return 'CREATE TABLE ' . $this->
_getTable()
261 .
' (pgt_iou VARCHAR(255) NOT NULL PRIMARY KEY, pgt VARCHAR(255) NOT NULL)';
272 return 'INSERT INTO ' . $this->
_getTable()
273 .
' (pgt_iou, pgt) VALUES (:pgt_iou, :pgt)';
285 return 'SELECT pgt FROM ' . $this->
_getTable() .
' WHERE pgt_iou = :pgt_iou';
296 return 'DELETE FROM ' . $this->
_getTable() .
' WHERE pgt_iou = :pgt_iou';
322 $pdo->beginTransaction();
324 $query =
$pdo->query($this->createTableSQL());
334 phpCAS::error(
'error creating PGT storage table: ' . $e->getMessage());
352 public function write($pgt, $pgt_iou)
361 $pdo->beginTransaction();
364 $query->bindValue(
':pgt', $pgt, PDO::PARAM_STR);
365 $query->bindValue(
':pgt_iou', $pgt_iou, PDO::PARAM_STR);
376 phpCAS::error(
'error writing PGT to database: ' . $e->getMessage());
403 $pdo->beginTransaction();
407 $query->bindValue(
':pgt_iou', $pgt_iou, PDO::PARAM_STR);
409 $pgt =
$query->fetchColumn(0);
414 $query->bindValue(
':pgt_iou', $pgt_iou, PDO::PARAM_STR);
425 phpCAS::trace(
'error reading PGT from database: ' . $e->getMessage());
_setErrorMode()
This method will enable the Exception error mode on the PDO object.
createTableSql()
This method returns the query used to create a pgt storage table.
Basic class for PGT database storage The CAS_PGTStorage_Db class is a class for PGT database storage...
__construct( $cas_parent, $dsn_or_pdo, $username='', $password='', $table='', $driver_options=null)
The class constructor.
$_pdo
the PDO object to use for database interactions
_resetErrorMode()
this method will reset the error mode on the PDO object
retrievePgtSql()
This method returns the query used to retrieve a pgt.
static error($msg)
This method is used by interface methods to print an error and where the function was originally call...
getStorageType()
This method returns an informational string giving the type of storage used by the object (used for d...
deletePgtSql()
This method returns the query used to delete a pgt.
$_dsn
database connection options to use when creating a new PDO object
init()
This method is used to initialize the storage.
isInitialized()
This method tells if the storage has already been intialized.
static traceEnd($res='')
This method is used to indicate the end of the execution of a function in debug mode.
static trace($str)
This method is used to log something in debug mode.
getStorageInfo()
This method returns an informational string giving informations on the parameters of the storage...
$_table
the table to use for storing/retrieving pgt's
Basic class for PGT storage The CAS_PGTStorage_AbstractStorage class is a generic class for PGT stora...
read($pgt_iou)
This method reads a PGT corresponding to a PGT Iou and deletes the corresponding db entry...
storePgtSql()
This method returns the query used to store a pgt.
_getTable()
This method returns the table to use when storing/retrieving PGT's.
write($pgt, $pgt_iou)
This method stores a PGT and its corresponding PGT Iou in the database.
_getPdo()
This method returns the PDO object to use for database interactions.
static traceBegin()
This method is used to indicate the start of the execution of a function in debug mode...
createTable()
This method creates the database table used to store pgt's and pgtiou's.
while(count($oldTaskList) > 0) foreach(array_keys($newTaskList) as $task) init()
if(empty($password)) $table
const CAS_PGT_STORAGE_DB_DEFAULT_TABLE
$_errMode
attribute that stores the previous error mode for the PDO handle while processing a transaction ...