From 2570226fbac3e26b1e94896b50d1db4bc1aa3308 Mon Sep 17 00:00:00 2001
From: wei <>
Date: Sun, 17 Dec 2006 22:20:50 +0000
Subject: Add TDataSourceConfig, TSqlMapConfig, TActiveRecordConfig
---
.../Data/ActiveRecord/TActiveRecordConfig.php | 108 +++++++++++++++++++++
1 file changed, 108 insertions(+)
create mode 100644 framework/Data/ActiveRecord/TActiveRecordConfig.php
(limited to 'framework/Data/ActiveRecord/TActiveRecordConfig.php')
diff --git a/framework/Data/ActiveRecord/TActiveRecordConfig.php b/framework/Data/ActiveRecord/TActiveRecordConfig.php
new file mode 100644
index 00000000..5670e64c
--- /dev/null
+++ b/framework/Data/ActiveRecord/TActiveRecordConfig.php
@@ -0,0 +1,108 @@
+
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright © 2005-2007 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Id$
+ * @package System.Data.ActiveRecord
+ */
+
+Prado::using('System.Data.TDataSourceConfig');
+
+/**
+ * TActiveRecordConfig module configuration class.
+ *
+ * Database configuration for the default ActiveRecord manager instance.
+ *
+ * Example: application.xml configuration
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ * MySQL database definition:
+ *
+ * CREATE TABLE `blogs` (
+ * `blog_id` int(10) unsigned NOT NULL auto_increment,
+ * `blog_name` varchar(255) NOT NULL,
+ * `blog_author` varchar(255) NOT NULL,
+ * PRIMARY KEY (`blog_id`)
+ * ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+ *
+ *
+ * Record php class:
+ *
+ * class Blogs extends TActiveRecord
+ * {
+ * public $blog_id;
+ * public $blog_name;
+ * public $blog_author;
+ *
+ * public static function finder()
+ * {
+ * return self::getRecordFinder('Blogs');
+ * }
+ * }
+ *
+ *
+ * Usage example:
+ *
+ * class Home extends TPage
+ * {
+ * function onLoad($param)
+ * {
+ * $blogs = Blogs::finder()->findAll();
+ * print_r($blogs);
+ * }
+ * }
+ *
+ *
+ * @author Wei Zhuo
+ * @version $Id$
+ * @package System.Data.ActiveRecord
+ * @since 3.1
+ */
+class TActiveRecordConfig extends TDataSourceConfig
+{
+ private $_enableCache=false;
+
+ /**
+ * Initialize the active record manager.
+ * @param TXmlDocument xml configuration.
+ */
+ public function init($xml)
+ {
+ parent::init($xml);
+ Prado::using('System.Data.ActiveRecord.TActiveRecordManager');
+ $manager = TActiveRecordManager::getInstance();
+ if($this->getEnableCache())
+ $manager->setCache($this->getApplication()->getCache());
+ $manager->setDbConnection($this->getDbConnection());
+ }
+
+ /**
+ * Set true to cache the table meta data.
+ * @param boolean true to cache sqlmap instance.
+ */
+ public function setEnableCache($value)
+ {
+ $this->_enableCache = TPropertyValue::ensureBoolean($value, false);
+ }
+
+ /**
+ * @return boolean true if table meta data should be cached, false otherwise.
+ */
+ public function getEnableCache()
+ {
+ return $this->_enableCache;
+ }
+}
+
+?>
\ No newline at end of file
--
cgit v1.2.3