~coughphp/coughphp/2.0

« back to all changes in this revision

Viewing changes to cough/CoughObject.class.php

  • Committer: Anthony Bush
  • Date: 2008-08-23 03:35:08 UTC
  • mfrom: (262.1.18 coughphp-release-1.3)
  • Revision ID: anthony@anthonybush.com-20080823033508-uy4yn5pmio6wcetv
Accept release-1.3 branch changes into trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
 * @package cough
13
13
 **/
14
14
abstract class CoughObject {
15
 
 
16
 
        /**
17
 
         * An array of all the columns in the database, including the primary key
18
 
         * column and name columns.
19
 
         *
20
 
         * Format of "field_name" => attributes
21
 
         *
22
 
         * @var array
23
 
         * @see defineFields()
24
 
         **/
25
 
        protected $fieldDefinitions = array();
26
 
        
27
 
        /**
28
 
         * An array of derived field definitions
29
 
         * 
30
 
         * Format of "derived_field_name" => attributes
31
 
         *
32
 
         * @var array
33
 
         * @see defineDerivedFields()
34
 
         **/
35
 
        protected $derivedFieldDefinitions = array();
36
 
        
37
 
        /**
38
 
         * An array of all the objects and their attributes.
39
 
         *
40
 
         * The information is used by CoughObject to instantiate and load the
41
 
         * objects.
42
 
         *
43
 
         * Format of [objectName] => [array of attributes]
44
 
         *
45
 
         * TODO: Document that array of attributes. For now just look at the
46
 
         * one of the generated class's defineObjects().
47
 
         *
48
 
         * @var array
49
 
         **/
50
 
        protected $objectDefinitions = array();
51
15
        
52
16
        /**
53
17
         * An array of all the currently initialized or set fields.
79
43
        protected $derivedFields = array();
80
44
        
81
45
        /**
 
46
         * An array of all the loaded objects in form [objectName] => [CoughObject]
 
47
         * 
 
48
         * @var array
 
49
         * @see getObject(), loadObject(), saveLoadedObjects(), isObjectLoaded()
 
50
         **/
 
51
        protected $objects = array();
 
52
        
 
53
        /**
82
54
         * An array of all the loaded collections in form [collectionName] => [CoughCollection]
83
55
         * 
84
56
         * @var array
85
57
         * @see getCollection(), loadCollection(), saveLoadedCollections(), isCollectionLoaded()
86
58
         **/
87
59
        protected $collections = array();
88
 
        
89
 
        /**
90
 
         * An array of all the loaded objects in form [objectName] => [CoughObject]
91
 
         * 
92
 
         * @var array
93
 
         * @see getObject(), loadObject(), saveLoadedObjects(), isObjectLoaded()
94
 
         **/
95
 
        protected $objects = array();
96
60
 
97
61
        /**
98
62
         * Stores whether or not the object has been deleted from the database.
137
101
         **/
138
102
        protected $validatedData = false;
139
103
 
 
104
        /**
 
105
         * An array of all the columns in the database, including the primary key
 
106
         * column and name columns.
 
107
         *
 
108
         * Format of "field_name" => attributes
 
109
         *
 
110
         * @var array
 
111
         * @see defineFields()
 
112
         **/
 
113
        protected $fieldDefinitions = array();
 
114
        
 
115
        /**
 
116
         * An array of derived field definitions
 
117
         * 
 
118
         * Format of "derived_field_name" => attributes
 
119
         *
 
120
         * @var array
 
121
         * @see defineDerivedFields()
 
122
         **/
 
123
        protected $derivedFieldDefinitions = array();
 
124
        
 
125
        /**
 
126
         * An array of all the objects and their attributes.
 
127
         *
 
128
         * The information is used by CoughObject to instantiate and load the
 
129
         * objects.
 
130
         *
 
131
         * Format of [objectName] => [array of attributes]
 
132
         *
 
133
         * TODO: Document that array of attributes. For now just look at the
 
134
         * one of the generated class's defineObjects().
 
135
         *
 
136
         * @var array
 
137
         **/
 
138
        protected $objectDefinitions = array();
 
139
 
140
140
        // ----------------------------------------------------------------------------------------------
141
141
        // CONSTRUCTORS and INITIALIZATION METHODS block BEGINS
142
142
        // ----------------------------------------------------------------------------------------------
214
214
         * @return mixed - CoughObject or null if no record found.
215
215
         * @todo PHP 5.3: switch from call_user_func to static::methodName() and remove the $className parameter
216
216
         **/
217
 
        public static function constructByKey($idOrHash, $className) {
 
217
        public static function constructByKey($idOrHash, $className = '') {
218
218
                if (is_array($idOrHash)) {
219
219
                        $fields = $idOrHash;
220
220
                } else {
247
247
         * @return mixed - CoughObject if exactly one row found, null otherwise.
248
248
         * @todo PHP 5.3: switch from call_user_func to static::methodName() and remove the $className parameter
249
249
         **/
250
 
        public static function constructBySql($sql, $className) {
 
250
        public static function constructBySql($sql, $className = '') {
251
251
                if (!empty($sql)) {
252
252
                        $db = call_user_func(array($className, 'getDb'));
253
253
                        $dbName = call_user_func(array($className, 'getDbName'));