From 25463c420866e639d0d4fd1a1b7be7dcc71b27fc Mon Sep 17 00:00:00 2001 From: xue <> Date: Wed, 16 Nov 2005 18:44:13 +0000 Subject: --- .gitattributes | 2 +- demos/personal/protected/Modules/DataModule.php | 120 ++++++++++++++++++++++++ demos/personal/protected/data/DataModule.php | 120 ------------------------ 3 files changed, 121 insertions(+), 121 deletions(-) create mode 100644 demos/personal/protected/Modules/DataModule.php delete mode 100644 demos/personal/protected/data/DataModule.php diff --git a/.gitattributes b/.gitattributes index 5b9b6d34..af4cbb96 100644 --- a/.gitattributes +++ b/.gitattributes @@ -17,6 +17,7 @@ demos/controls/themes/BlueTheme/buttons.skin -text demos/controls/themes/BlueTheme/icon_profile.gif -text demos/controls/themes/BlueTheme/labels.skin -text demos/personal/index.php -text +demos/personal/protected/Modules/DataModule.php -text demos/personal/protected/Pages/HomePage.php -text demos/personal/protected/Pages/HomePage.tpl -text demos/personal/protected/Pages/Layout.php -text @@ -25,7 +26,6 @@ demos/personal/protected/Pages/LoginPage.php -text demos/personal/protected/Pages/LoginPage.tpl -text demos/personal/protected/Pages/config.xml -text demos/personal/protected/application.xml -text -demos/personal/protected/data/DataModule.php -text demos/personal/protected/data1/DataModule.php -text demos/personal/themes/BlueTheme/buttons.skin -text demos/personal/themes/BlueTheme/icon_profile.gif -text diff --git a/demos/personal/protected/Modules/DataModule.php b/demos/personal/protected/Modules/DataModule.php new file mode 100644 index 00000000..03ee3496 --- /dev/null +++ b/demos/personal/protected/Modules/DataModule.php @@ -0,0 +1,120 @@ +_db=null; + parent::__destruct(); + } + + /** + * Initializes this module. + * This method is required by the IModule interface. It checks if the DbFile + * property is set, and creates a SQLiteDatabase instance for it. + * If the database or the tables do not exist, they will be created. + * @param IApplication Prado application, can be null + * @param TXmlElement configuration for this module, can be null + * @throws TConfigurationException DbFile is set invalid + */ + public function init($application,$config) + { + if(!function_exists('sqlite_open')) + throw new TConfigurationException('SQLite extension required.'); + if($this->_file===null) + throw new TConfigurationException('SQLite db file required.'); + if(($fname=Prado::getPathOfNamespace($this->_file,self::DB_FILE_EXT))===null) + throw new TConfigurationException('SQLite db file invalid: '.$this->_file); + $error=''; + if(($this->_db=new SQLiteDatabase($fname,0666,$error))===false) + throw new TConfigurationException('SQLite db connection failed: ',$error); + $res=$this->_db->query('SELECT * FROM sqlite_master WHERE tbl_name=\'tblBlogs\' AND type=\'table\''); + if($res===false || $res->numRows()===0 && $this->_db->query(self::DB_SCHEMA)===false) + throw new TConfigurationException('SQLite db table creation failed: '.sqlite_error_string(sqlite_last_error())); + $this->_initialized=true; + } + + /** + * @return string id of this module + */ + public function getID() + { + return $this->_id; + } + + /** + * @param string id of this module + */ + public function setID($value) + { + $this->_id=$value; + } + + /** + * @return string database file path (in namespace form) + */ + public function getDbFile() + { + return $this->_file; + } + + /** + * @param string database file path (in namespace form) + * @throws TInvalidOperationException if the module is already initialized + */ + public function setDbFile($value) + { + if($this->_initialized) + throw new TInvalidOperationException('DbFile cannot be modified after the module is initialized.'); + else + $this->_file=$value; + } + + public function getBlogsByTime($time) + { + } +} + +class Blog +{ + public $id; + public $title; + public $author; + public $content; + public $lastupdate; + public $comments; +} + +class Comment +{ + public $id; + public $bid; + public $author; + public $content; + public $lastupdate; +} + +?> \ No newline at end of file diff --git a/demos/personal/protected/data/DataModule.php b/demos/personal/protected/data/DataModule.php deleted file mode 100644 index 03ee3496..00000000 --- a/demos/personal/protected/data/DataModule.php +++ /dev/null @@ -1,120 +0,0 @@ -_db=null; - parent::__destruct(); - } - - /** - * Initializes this module. - * This method is required by the IModule interface. It checks if the DbFile - * property is set, and creates a SQLiteDatabase instance for it. - * If the database or the tables do not exist, they will be created. - * @param IApplication Prado application, can be null - * @param TXmlElement configuration for this module, can be null - * @throws TConfigurationException DbFile is set invalid - */ - public function init($application,$config) - { - if(!function_exists('sqlite_open')) - throw new TConfigurationException('SQLite extension required.'); - if($this->_file===null) - throw new TConfigurationException('SQLite db file required.'); - if(($fname=Prado::getPathOfNamespace($this->_file,self::DB_FILE_EXT))===null) - throw new TConfigurationException('SQLite db file invalid: '.$this->_file); - $error=''; - if(($this->_db=new SQLiteDatabase($fname,0666,$error))===false) - throw new TConfigurationException('SQLite db connection failed: ',$error); - $res=$this->_db->query('SELECT * FROM sqlite_master WHERE tbl_name=\'tblBlogs\' AND type=\'table\''); - if($res===false || $res->numRows()===0 && $this->_db->query(self::DB_SCHEMA)===false) - throw new TConfigurationException('SQLite db table creation failed: '.sqlite_error_string(sqlite_last_error())); - $this->_initialized=true; - } - - /** - * @return string id of this module - */ - public function getID() - { - return $this->_id; - } - - /** - * @param string id of this module - */ - public function setID($value) - { - $this->_id=$value; - } - - /** - * @return string database file path (in namespace form) - */ - public function getDbFile() - { - return $this->_file; - } - - /** - * @param string database file path (in namespace form) - * @throws TInvalidOperationException if the module is already initialized - */ - public function setDbFile($value) - { - if($this->_initialized) - throw new TInvalidOperationException('DbFile cannot be modified after the module is initialized.'); - else - $this->_file=$value; - } - - public function getBlogsByTime($time) - { - } -} - -class Blog -{ - public $id; - public $title; - public $author; - public $content; - public $lastupdate; - public $comments; -} - -class Comment -{ - public $id; - public $bid; - public $author; - public $content; - public $lastupdate; -} - -?> \ No newline at end of file -- cgit v1.2.3