From 3d3f8d3832921f99daf8ce1953304763c2e76c62 Mon Sep 17 00:00:00 2001 From: wei <> Date: Fri, 14 Apr 2006 06:22:09 +0000 Subject: Importing SQLMap + sample + docs. --- framework/DataAccess/SQLMap/TMapper.php | 60 +++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 framework/DataAccess/SQLMap/TMapper.php (limited to 'framework/DataAccess/SQLMap/TMapper.php') diff --git a/framework/DataAccess/SQLMap/TMapper.php b/framework/DataAccess/SQLMap/TMapper.php new file mode 100644 index 00000000..4427c012 --- /dev/null +++ b/framework/DataAccess/SQLMap/TMapper.php @@ -0,0 +1,60 @@ + + * TMapper::configure($configFile); + * $object = TMapper::instance()->queryForObject('statementName'); + * + * + * If your configuration file is named 'sqlmap.config' you may skip the + * configure() call. + * + * @author Wei Zhuo + * @version $Revision: $ $Date: $ + * @package System.DataAccess.SQLMap + * @since 3.0 + */ +class TMapper +{ + /** + * Data mapper singleton + * @var TSqlMapper + */ + private static $_mapper; + + /** + * Configure the data mapper singleton instance. + * @param string configuration file + * @param boolean true to load configuration from cache. + * @return TSqlMapper data mapper instance. + */ + public static function configure($configFile,$loadCachedConfig=false) + { + if(is_null(self::$_mapper)) + { + $sqlmap = new TSQLMapClient; + self::$_mapper = $sqlmap->configure($configFile,$loadCachedConfig); + } + return self::$_mapper; + } + + /** + * Gets the data mapper singleton instance. Default configuration file is + * 'sqlmap.config'. + * @return TSqlMapper singleton instance. + */ + public static function instance() + { + if(is_null(self::$_mapper)) + self::configure('sqlmap.xml'); + return self::$_mapper; + } +} + +?> \ No newline at end of file -- cgit v1.2.3