diff options
author | godzilla80@gmx.net <> | 2010-02-13 19:04:45 +0000 |
---|---|---|
committer | godzilla80@gmx.net <> | 2010-02-13 19:04:45 +0000 |
commit | 966fd66f217911d079c4bd6a87b09f4a0c5c4736 (patch) | |
tree | 26d4cda965ed5a6ddf2aeb805fcef42877584fd3 /framework/Testing/Data/Analysis/TDbStatementAnalysis.php | |
parent | 879cced5e01d43378065c938483b55a35ff10834 (diff) |
NEW: Add Beta of master/slave senario solution
- add package System.Testing.Data.Analysis
- add package System.Testing.Data.Distributed
- add sub package System.Testing.Data.Distributed.MasterSlave
- add unittest for System.Testing.Data.Analysis
Diffstat (limited to 'framework/Testing/Data/Analysis/TDbStatementAnalysis.php')
-rw-r--r-- | framework/Testing/Data/Analysis/TDbStatementAnalysis.php | 238 |
1 files changed, 238 insertions, 0 deletions
diff --git a/framework/Testing/Data/Analysis/TDbStatementAnalysis.php b/framework/Testing/Data/Analysis/TDbStatementAnalysis.php new file mode 100644 index 00000000..46f9b745 --- /dev/null +++ b/framework/Testing/Data/Analysis/TDbStatementAnalysis.php @@ -0,0 +1,238 @@ +<?php +/** + * IDbStatementAnalysis, TDbStatementAnalysisParameter, + * TDbStatementAnalysis, TDbStatementClassification file. + * + * @author Yves Berkholz <godzilla80[at]gmx[dot]net> + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2005-2010 PradoSoft + * @license http://www.pradosoft.com/license/ + * @version $Id$ + * @package System.Testing.Data.Analysis + */ + + /** + * IDbStatementAnalysis interface + * + * @author Yves Berkholz <godzilla80[at]gmx[dot]net> + * @license http://www.pradosoft.com/license/ + * @version $Id$ + * @package System.Testing.Data.Analysis + * @since 4.0 + */ + interface IDbStatementAnalysis + { + /** + * @param TDbStatementAnalysisParamete + * @return TDbStatementClassification + */ + public static function doClassificationAnalysis(TDbStatementAnalysisParameter $param); + + /** + * @param TDbStatementAnalysisParameter + * @return TDbStatementClassification + */ + public function getClassificationAnalysis(TDbStatementAnalysisParameter $param); + + /** + * @param string PDO drivername of connection + */ + public function setDriverName($value); + + /** + * @return string PDO drivername of connection + */ + public function getDriverName(); + } + + /** + * TDbStatementAnalysisParameter class + * + * + * @author Yves Berkholz <godzilla80[at]gmx[dot]net> + * @license http://www.pradosoft.com/license/ + * @version $Id$ + * @package System.Testing.Data.Analysis + * @since 4.0 + */ + class TDbStatementAnalysisParameter + { + /** + * @var string The SQL statement that should be analysed + */ + protected $_statement = null; + + /** + * TDbStatementClassification Defaults to 'UNKNOWN' + */ + protected $_defaultClassification = TDbStatementClassification::UNKNOWN; + + /** + * string|null PDO drivername of connection + */ + protected $_drivername = null; + + /** + * @param string The SQL statement that should be analysed + * @param TDbStatementClassification + * @param string|null PDO drivername of connection + */ + public function __construct($statement='', $defaultClassification=null, $drivername=null) + { + $this->setStatement($statement); + $this->setDefaultClassification($defaultClassification); + $this->setDriverName($drivername); + } + + /** + * @param string The SQL statement that should be analysed + */ + public function setStatement($value) + { + $this->_statement = (string)$value; + } + + /** + * @return string The SQL statement that should be analysed + */ + public function getStatement() + { + return $this->_statement; + } + + /** + * @param string|null PDO drivername of connection + */ + public function setDriverName($value) + { + $this->_drivername = ($value===null) ? null : (string)$value; + } + + /** + * @return string|null PDO drivername of connection + */ + public function getDriverName() + { + return $this->_drivername; + } + + /** + * @param TDbStatementClassification Defaults to 'UNKNOWN' + */ + public function setDefaultClassification($value) + { + if($value!==null) + $this->_defaultClassification = (string)$value; + else + $this->_defaultClassification = TDbStatementClassification::UNKNOWN; + } + + /** + * @return TDbStatementClassification + */ + public function getDefaultClassification() + { + return $this->_defaultClassification; + } + } + + /** + * TDbStatementAnalysis class + * + * Basic "dummy" implementation allways return {@link TDbStatementAnalysisParameter::getDefaultClassification DefaultClassification} + * + * @author Yves Berkholz <godzilla80[at]gmx[dot]net> + * @license http://www.pradosoft.com/license/ + * @version $Id$ + * @package System.Testing.Data.Analysis + * @since 4.0 + */ + class TDbStatementAnalysis implements IDbStatementAnalysis + { + /** + * @var string|null PDO drivername of connection + */ + protected $_drivername = null; + + /** + * @param string|null PDO drivername of connection + */ + public function setDriverName($value) + { + $this->_drivername = ($value===null) ? null : (string)$value; + } + + /** + * @return string|null PDO drivername of connection + */ + public function getDriverName() + { + return $this->_drivername; + } + + /** + * @param TDbStatementAnalysisParamete + * @return TDbStatementClassification + */ + public static function doClassificationAnalysis(TDbStatementAnalysisParameter $param) + { + return $param->getDefaultClassification(); + } + + /** + * @param TDbStatementAnalysisParameter + * @return TDbStatementClassification + */ + public function getClassificationAnalysis(TDbStatementAnalysisParameter $param) + { + return $param->getDefaultClassification(); + } + } + + /** + * TDbStatementClassification + * + * @author Yves Berkholz <godzilla80[at]gmx[dot]net> + * @license http://www.pradosoft.com/license/ + * @version $Id$ + * @package System.Testing.Data.Analysis + * @since 4.0 + */ + class TDbStatementClassification extends TEnumerable + { + /** + * Structured Query Language + */ + const SQL = 'SQL'; + + /** + * Data Definition Language + */ + const DDL = 'DDL'; + + /** + * Data Manipulation Language + */ + const DML = 'DML'; + + /** + * Data Control Language + */ + const DCL = 'DCL'; + + /** + * Transaction Control Language + */ + const TCL = 'TCL'; + + /** + * classification depends on subsequent statement(s) + */ + const CONTEXT = 'CONTEXT'; + + /** + * unable to detect real classification or multiple possibilities + */ + const UNKNOWN = 'UNKNOWN'; + } +?> |