Commit 4bee9e84 by Qiang Xue

Merge pull request #1852 from creocoder/activerecord-tablename-prefix-fixes

[WIP] ActiveRecord::tableName() hardcoded prefix fix
parents d9dd7292 ecf7942a
......@@ -63,7 +63,7 @@ class DbCache extends Cache
* When using DbCache in a production server, we recommend you create a DB index for the 'expire'
* column in the cache table to improve the performance.
*/
public $cacheTable = 'tbl_cache';
public $cacheTable = '{{%cache}}';
/**
* @var integer the probability (parts per million) that garbage collection (GC) should be performed
* when storing a piece of data in the cache. Defaults to 100, meaning 0.01% chance.
......
......@@ -73,7 +73,7 @@ class MigrateController extends Controller
/**
* @var string the name of the table for keeping applied migration information.
*/
public $migrationTable = 'tbl_migration';
public $migrationTable = '{{%migration}}';
/**
* @var string the template file for generating new migrations.
* This can be either a path alias (e.g. "@app/migrations/template.php")
......
......@@ -177,13 +177,14 @@ class ActiveRecord extends BaseActiveRecord
/**
* Declares the name of the database table associated with this AR class.
* By default this method returns the class name as the table name by calling [[Inflector::camel2id()]]
* with prefix 'tbl_'. For example, 'Customer' becomes 'tbl_customer', and 'OrderItem' becomes
* 'tbl_order_item'. You may override this method if the table is not named after this convention.
* with prefix [[DbConnection::tablePrefix]]. For example if [[DbConnection::tablePrefix]] is 'tbl_',
* 'Customer' becomes 'tbl_customer', and 'OrderItem' becomes 'tbl_order_item'. You may override this method
* if the table is not named after this convention.
* @return string the table name
*/
public static function tableName()
{
return 'tbl_' . Inflector::camel2id(StringHelper::basename(get_called_class()), '_');
return '{{%' . Inflector::camel2id(StringHelper::basename(get_called_class()), '_') . '}}';
}
/**
......
......@@ -219,10 +219,9 @@ class Connection extends Component
/**
* @var string the common prefix or suffix for table names. If a table name is given
* as `{{%TableName}}`, then the percentage character `%` will be replaced with this
* property value. For example, `{{%post}}` becomes `{{tbl_post}}` if this property is
* set as `"tbl_"`.
* property value. For example, `{{%post}}` becomes `{{tbl_post}}`.
*/
public $tablePrefix;
public $tablePrefix = 'tbl_';
/**
* @var array mapping between PDO driver names and [[Schema]] classes.
* The keys of the array are PDO driver names while the values the corresponding
......
......@@ -68,11 +68,11 @@ class DbMessageSource extends MessageSource
/**
* @var string the name of the source message table.
*/
public $sourceMessageTable = 'tbl_source_message';
public $sourceMessageTable = '{{%source_message}}';
/**
* @var string the name of the translated message table.
*/
public $messageTable = 'tbl_message';
public $messageTable = '{{%message}}';
/**
* @var integer the time in seconds that the messages can remain valid in cache.
* Use 0 to indicate that the cached data will never expire.
......
......@@ -52,7 +52,7 @@ class DbTarget extends Target
* of some queries about message levels and categories. Depending on your actual needs, you may
* want to create additional indexes (e.g. index on `log_time`).
*/
public $logTable = 'tbl_log';
public $logTable = '{{%log}}';
/**
* Initializes the DbTarget component.
......
......@@ -41,15 +41,15 @@ class DbManager extends Manager
/**
* @var string the name of the table storing authorization items. Defaults to 'tbl_auth_item'.
*/
public $itemTable = 'tbl_auth_item';
public $itemTable = '{{%auth_item}}';
/**
* @var string the name of the table storing authorization item hierarchy. Defaults to 'tbl_auth_item_child'.
*/
public $itemChildTable = 'tbl_auth_item_child';
public $itemChildTable = '{{%auth_item_child}';
/**
* @var string the name of the table storing authorization item assignments. Defaults to 'tbl_auth_assignment'.
*/
public $assignmentTable = 'tbl_auth_assignment';
public $assignmentTable = '{{%auth_assignment}}';
private $_usingSqlite;
......
......@@ -65,7 +65,7 @@ class DbSession extends Session
* When using DbSession in a production server, we recommend you create a DB index for the 'expire'
* column in the session table to improve the performance.
*/
public $sessionTable = 'tbl_session';
public $sessionTable = '{{%session}}';
/**
* Initializes the DbSession component.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment