Changeset 1750
- Timestamp:
- 03/06/2007 02:40:51 PM (21 months ago)
- Location:
- trunk
- Files:
-
- 21 modified
-
UPGRADE (modified) (1 diff)
-
demos/address-book/protected/pages/AddressRecord.php (modified) (1 diff)
-
demos/chat/protected/App_Code/ChatBufferRecord.php (modified) (2 diffs)
-
demos/chat/protected/App_Code/ChatUserRecord.php (modified) (1 diff)
-
demos/quickstart/protected/controls/Comments/CommentBlock.php (modified) (2 diffs)
-
demos/quickstart/protected/pages/Database/ActiveRecord.page (modified) (3 diffs)
-
demos/quickstart/protected/pages/Database/Samples/Scaffold/Home.php (modified) (1 diff)
-
demos/quickstart/protected/pages/Database/Scaffold.page (modified) (1 diff)
-
demos/quickstart/protected/pages/Database/SqlMap.page (modified) (1 diff)
-
demos/quickstart/protected/pages/Tutorial/AjaxChat.page (modified) (3 diffs)
-
demos/quickstart/protected/pages/Tutorial/fr/AjaxChat.page (modified) (3 diffs)
-
framework/Data/ActiveRecord/Exceptions/messages.txt (modified) (1 diff)
-
framework/Data/ActiveRecord/TActiveRecord.php (modified) (1 diff)
-
framework/Data/ActiveRecord/TActiveRecordGateway.php (modified) (3 diffs)
-
framework/prado-cli.php (modified) (2 diffs)
-
tests/simple_unit/ActiveRecord/records/DepSections.php (modified) (1 diff)
-
tests/simple_unit/ActiveRecord/records/DepartmentRecord.php (modified) (1 diff)
-
tests/simple_unit/ActiveRecord/records/SimpleUser.php (modified) (1 diff)
-
tests/simple_unit/ActiveRecord/records/SqliteUsers.php (modified) (1 diff)
-
tests/simple_unit/ActiveRecord/records/UserRecord.php (modified) (1 diff)
-
tests/simple_unit/SqlMap/ActiveRecordSqlMapTest.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/UPGRADE
r1749 r1750 12 12 Upgrading from v3.1a 13 13 --------------------- 14 - The signature of TActiveRecord::finder() is changed. All TActiveRecord-descendant15 classes that override this method will be affected. Please use the16 following code to override the method:14 - The signature of TActiveRecord::finder() is changed. This affects 15 all TActiveRecord-descendant classes that override this method. 16 Please use the following code to override the method: 17 17 public static function finder($className=__CLASS__) 18 18 { 19 19 return parent::finder($className); 20 20 } 21 22 - The way to specify the table name for an active record class is changed. 23 Previously, it used the static class member '_tablename'. 24 Now it uses class constant as follows: 25 class UserRecord extends TActiveRecord 26 { 27 const TABLE='users_table'; 28 } 21 29 22 30 Upgrading from v3.0.x -
trunk/demos/address-book/protected/pages/AddressRecord.php
r1748 r1750 5 5 class AddressRecord extends TActiveRecord 6 6 { 7 public static $_tablename='addresses';7 const TABLE='addresses'; 8 8 9 9 /** -
trunk/demos/chat/protected/App_Code/ChatBufferRecord.php
r1729 r1750 3 3 class ChatBufferRecord extends TActiveRecord 4 4 { 5 const TABLE='chat_buffer'; 6 5 7 public $id; 6 8 public $for_user; … … 8 10 public $message; 9 11 private $_created_on; 10 11 public static $_tablename='chat_buffer';12 12 13 13 public function getCreated_On() -
trunk/demos/chat/protected/App_Code/ChatUserRecord.php
r1729 r1750 3 3 class ChatUserRecord extends TActiveRecord 4 4 { 5 const TABLE='chat_users'; 6 5 7 public $username; 6 8 private $_last_activity; 7 8 public static $_tablename='chat_users';9 9 10 10 public function getLast_Activity() -
trunk/demos/quickstart/protected/controls/Comments/CommentBlock.php
r1729 r1750 11 11 class CommentRecord extends TActiveRecord 12 12 { 13 const TABLE='qs_comments'; 14 13 15 public $id; 14 16 public $username; … … 17 19 public $block_id; 18 20 public $content; 19 20 public static $_tablename='qs_comments';21 21 22 22 public static function finder($className=__CLASS__) -
trunk/demos/quickstart/protected/pages/Database/ActiveRecord.page
r1729 r1750 74 74 class UserRecord extends TActiveRecord 75 75 { 76 const TABLE='users'; //table name 77 76 78 public $username; //the column named "username" in the "users" table 77 79 public $email; 78 79 public static $_tablename='users'; //table name80 80 81 81 /** … … 90 90 </p> 91 91 <p id="690485" class="block-content">Each property of the <tt>UserRecord</tt> class must correspond to a 92 column with the same name in the "users" table. The static class variable93 <tt> $_tablename</tt> (must be public)is optional when the class name is the same as94 the table name in the database, otherwise <tt> $_tablename</tt> must92 column with the same name in the "users" table. The class constant 93 <tt>TABLE</tt> is optional when the class name is the same as 94 the table name in the database, otherwise <tt>TABLE</tt> must 95 95 specify the table name that corresponds to your Active Record class. 96 96 </p> 97 97 98 98 <div class="note"><b class="note">Note:</b> 99 You may need to quote (specific to your database) the value of the <tt> $_tablename</tt>.100 E.g. MySQL uses back-ticks, <tt> $_tablename= "`database1`.`table1`"</tt>99 You may need to quote (specific to your database) the value of the <tt>TABLE</tt>. 100 E.g. MySQL uses back-ticks, <tt>TABLE = "`database1`.`table1`"</tt> 101 101 </div> 102 102 … … 121 121 122 122 <div class="info"><b class="note">Info:</b> 123 <tt>TActiveRecord</tt> can also work with database views by specifying the value <tt>$_tablename</tt>123 <tt>TActiveRecord</tt> can also work with database views by specifying the constant <tt>TABLE</tt> 124 124 corresponding to the view name. However, objects returned 125 125 from views are read-only, calling the <tt>save()</tt> or <tt>delete()</tt> method -
trunk/demos/quickstart/protected/pages/Database/Samples/Scaffold/Home.php
r1664 r1750 6 6 class AddressRecord extends TActiveRecord 7 7 { 8 const TABLE='addresses'; 9 8 10 public $id; 9 11 public $username; 10 12 public $phone; 11 12 public static $_tablename='addresses';13 13 14 14 //for demo, we use static db here -
trunk/demos/quickstart/protected/pages/Database/Scaffold.page
r1664 r1750 40 40 class UserRecord extends TActiveRecord 41 41 { 42 const TABLE='users'; 43 42 44 public $username; 43 45 public $email; 44 45 public static $_tablename='users';46 46 } 47 47 </com:TTextHighlighter> -
trunk/demos/quickstart/protected/pages/Database/SqlMap.page
r1729 r1750 214 214 class UserRecord extends TActiveRecord 215 215 { 216 const TABLE='users'; //table name 217 216 218 public $username; //the column named "username" in the "users" table 217 219 public $email; 218 219 private static $_tablename='users'; //table name 220 220 221 221 /** 222 222 * @return TActiveRecord active record finder instance -
trunk/demos/quickstart/protected/pages/Tutorial/AjaxChat.page
r1729 r1750 169 169 class ChatUserRecord extends TActiveRecord 170 170 { 171 const TABLE='chat_users'; 172 171 173 public $username; 172 174 public $last_activity; 173 174 public static $_tablename='chat_users';175 175 176 176 public static function finder($className=__CLASS__) … … 503 503 class ChatBufferRecord extends TActiveRecord 504 504 { 505 const TABLE='chat_buffer'; 506 505 507 public $id; 506 508 public $for_user; … … 508 510 public $message; 509 511 private $_created_on; 510 511 public static $_tablename='chat_buffer';512 512 513 513 public function getCreated_On() -
trunk/demos/quickstart/protected/pages/Tutorial/fr/AjaxChat.page
r1729 r1750 169 169 class ChatUserRecord extends TActiveRecord 170 170 { 171 const TABLE='chat_users'; 172 171 173 public $username; 172 174 public $last_activity; 173 174 public static $_tablename='chat_users';175 175 176 176 public static function finder($className=__CLASS__) … … 503 503 class ChatBufferRecord extends TActiveRecord 504 504 { 505 const TABLE='chat_buffer'; 506 505 507 public $id; 506 508 public $for_user; … … 508 510 public $message; 509 511 private $_created_on; 510 511 public static $_tablename='chat_buffer';512 512 513 513 public function getCreated_On() -
trunk/framework/Data/ActiveRecord/Exceptions/messages.txt
r1729 r1750 10 10 ar_invalid_db_connection = Missing or invalid default database connection for ActiveRecord class '{0}', default connection is set by the DbConnection property of TActiveRecordManager. 11 11 ar_mismatch_args_exception = ActiveRecord finder method '{0}' expects {1} parameters but found only {2} parameters instead. 12 ar_invalid_tablename_property = ActiveRecord tablename property '{0}::${1}' must be static and not null.12 ar_invalid_tablename_property = Constant {0}::{1} must be a valid database table name. 13 13 ar_value_must_not_be_null = Property '{0}::${2}' must not be null as defined by column '{2}' in table '{1}'. 14 14 ar_missing_pk_values = Missing primary key values in forming IN(key1, key2, ...) for table '{0}'. -
trunk/framework/Data/ActiveRecord/TActiveRecord.php
r1749 r1750 36 36 * class UserRecord extends TActiveRecord 37 37 * { 38 * const TABLE='users'; //optional table name. 39 * 38 40 * public $username; //corresponds to the fieldname in the table 39 41 * public $email; 40 *41 * public static final $_tablename='users'; //optional table name.42 42 * 43 43 * //returns active record finder instance -
trunk/framework/Data/ActiveRecord/TActiveRecordGateway.php
r1728 r1750 26 26 27 27 /** 28 * Property name foroptional table name in TActiveRecord.29 */ 30 const PROPERTY_TABLE_NAME='_tablename';28 * Constant name for specifying optional table name in TActiveRecord. 29 */ 30 const TABLE_CONST='TABLE'; 31 31 32 32 /** … … 48 48 49 49 /** 50 * Gets the table name from the $_tablename propertyof the active record50 * Gets the table name from the 'TABLE' constant of the active record 51 51 * class if defined, otherwise use the class name as table name. 52 52 * @param TActiveRecord active record instance … … 56 56 { 57 57 $class = new ReflectionClass($record); 58 if($class->has Property(self::PROPERTY_TABLE_NAME))58 if($class->hasConstant(self::TABLE_CONST)) 59 59 { 60 $value = $class->get Property(self::PROPERTY_TABLE_NAME)->getValue();61 if( $value===null)60 $value = $class->getConstant(self::TABLE_CONST); 61 if(empty($value)) 62 62 throw new TActiveRecordException('ar_invalid_tablename_property', 63 get_class($record),self:: PROPERTY_TABLE_NAME);63 get_class($record),self::TABLE_CONST); 64 64 return $value; 65 65 } -
trunk/framework/prado-cli.php
r1729 r1750 648 648 { 649 649 $props = implode("\n", $properties); 650 $table = '$_tablename=\''.$tablename.'\'';651 650 $date = date('Y-m-d h:i:s'); 652 651 return <<<EOD … … 657 656 class $class extends TActiveRecord 658 657 { 659 public static $table;658 const TABLE='$tablename'; 660 659 661 660 $props -
trunk/tests/simple_unit/ActiveRecord/records/DepSections.php
r1729 r1750 6 6 public $order; 7 7 8 public static $_tablename='department_sections';8 const TABLE='department_sections'; 9 9 10 10 public static function finder($className=__CLASS__) -
trunk/tests/simple_unit/ActiveRecord/records/DepartmentRecord.php
r1729 r1750 8 8 public $order; 9 9 10 public static $_tablename= 'departments';10 const TABLE = 'departments'; 11 11 12 12 public static function finder($className=__CLASS__) -
trunk/tests/simple_unit/ActiveRecord/records/SimpleUser.php
r1729 r1750 4 4 public $username; 5 5 6 public static $_tablename='simple_users';6 const TABLE='simple_users'; 7 7 8 8 public static function finder($className=__CLASS__) -
trunk/tests/simple_unit/ActiveRecord/records/SqliteUsers.php
r1729 r1750 6 6 public $email; 7 7 8 public static $_tablename='users';8 const TABLE='users'; 9 9 10 10 public static function finder($className=__CLASS__) -
trunk/tests/simple_unit/ActiveRecord/records/UserRecord.php
r1729 r1750 18 18 private $_level=-1; 19 19 20 public static $_tablename='users';20 const TABLE='users'; 21 21 22 22 public function getLevel() -
trunk/tests/simple_unit/SqlMap/ActiveRecordSqlMapTest.php
r1729 r1750 15 15 public $Account_Cart_Option; 16 16 17 private static $_tablename='Accounts';17 const TABLE='Accounts'; 18 18 19 19 public static function finder($className=__CLASS__)
