From 966fd66f217911d079c4bd6a87b09f4a0c5c4736 Mon Sep 17 00:00:00 2001 From: "godzilla80@gmx.net" <> Date: Sat, 13 Feb 2010 19:04:45 +0000 Subject: 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 --- .../Testing/Data/Analysis/TDbStatementAnalysis.php | 238 +++++++++++++++++++++ 1 file changed, 238 insertions(+) create mode 100644 framework/Testing/Data/Analysis/TDbStatementAnalysis.php (limited to 'framework/Testing/Data/Analysis/TDbStatementAnalysis.php') 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 @@ + + * @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 + * @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 + * @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 + * @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 + * @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'; + } +?> -- cgit v1.2.3