From a8b3ebe8f62c3888b216d827c1c5dcba8a47d4e1 Mon Sep 17 00:00:00 2001 From: wei <> Date: Sun, 26 Nov 2006 22:15:58 +0000 Subject: Adding active record implementation. --- .../Exceptions/TActiveRecordException.php | 39 ++++++++++++++++++++++ .../Data/ActiveRecord/Exceptions/messages.txt | 12 +++++++ 2 files changed, 51 insertions(+) create mode 100644 framework/Data/ActiveRecord/Exceptions/TActiveRecordException.php create mode 100644 framework/Data/ActiveRecord/Exceptions/messages.txt (limited to 'framework/Data/ActiveRecord/Exceptions') diff --git a/framework/Data/ActiveRecord/Exceptions/TActiveRecordException.php b/framework/Data/ActiveRecord/Exceptions/TActiveRecordException.php new file mode 100644 index 00000000..ec177a84 --- /dev/null +++ b/framework/Data/ActiveRecord/Exceptions/TActiveRecordException.php @@ -0,0 +1,39 @@ + + * @version $Id$ + * @package System.Data.ActiveRecord.Exceptions + */ + +/** + * Base exception class for Active Records. + * + * @author Wei Zhuo + * @version $Id$ + * @package System.Data.ActiveRecord.Exceptions + * @since 3.1 + */ +class TActiveRecordException extends TException +{ + /** + * @return string path to the error message file + */ + protected function getErrorMessageFile() + { + $lang=Prado::getPreferredLanguage(); + $path = dirname(__FILE__); + $msgFile=$path.'/messages-'.$lang.'.txt'; + if(!is_file($msgFile)) + $msgFile=$path.'/messages.txt'; + return $msgFile; + } +} + +class TActiveRecordConfigurationException extends TActiveRecordException +{ + +} + +?> \ No newline at end of file diff --git a/framework/Data/ActiveRecord/Exceptions/messages.txt b/framework/Data/ActiveRecord/Exceptions/messages.txt new file mode 100644 index 00000000..f77b2275 --- /dev/null +++ b/framework/Data/ActiveRecord/Exceptions/messages.txt @@ -0,0 +1,12 @@ +ar_readonly_exception = Active Record '{0}' is read only. +ar_object_must_be_retrieved_before_delete = Active Record must be retrieved first before deletion. +ar_object_must_not_be_null = Active record object must not be null. +ar_object_marked_for_removal = Active record object already marked for removed. +ar_column_meta_data_read_only = Column meta is read only. +ar_invalid_database_driver = Active Record does not support database '{0}'. +ar_invalid_finder_method = Unsupported Active Record finder method '{0}'. +ar_no_primary_key_found = Table '{0}' does not contain any primary key fields. +ar_primary_key_is_scalar = Primary key '{1}' in table '{0}' is NOT a composite key, invalid value '{2} used. +ar_invalid_db_connection = Missing or invalid default database connection for ActiveRecord class '{0}', default connection is set by the DbConnection property of TActiveRecordManager. +ar_mismatch_args_exception = ActiveRecord finder method '{0}' expects {1} parameters but found only {2} parameters instead. +ar_invalid_tablename_property = ActiveRecord tablename property '{0}::${1}' must be static and not null. \ No newline at end of file -- cgit v1.2.3