PHP 클래스 yii\db\Connection

Connection works together with Command, DataReader and Transaction to provide data access to various DBMS in a common set of APIs. They are a thin wrapper of the [[PDO PHP extension]](http://www.php.net/manual/en/ref.pdo.php). Connection supports database replication and read-write splitting. In particular, a Connection component can be configured with multiple [[masters]] and [[slaves]]. It will do load balancing and failover by choosing appropriate servers. It will also automatically direct read operations to the slaves and write operations to the masters. To establish a DB connection, set [[dsn]], [[username]] and [[password]], and then call Connection::open to be true. The following example shows how to create a Connection instance and establish the DB connection: ~~~ $connection = new \yii\db\Connection([ 'dsn' => $dsn, 'username' => $username, 'password' => $password, ]); $connection->open(); ~~~ After the DB connection is established, one can execute SQL statements like the following: ~~~ $command = $connection->createCommand('SELECT * FROM post'); $posts = $command->queryAll(); $command = $connection->createCommand('UPDATE post SET status=1'); $command->execute(); ~~~ One can also do prepared SQL execution and bind parameters to the prepared SQL. When the parameters are coming from user input, you should use this approach to prevent SQL injection attacks. The following is an example: ~~~ $command = $connection->createCommand('SELECT * FROM post WHERE id=:id'); $command->bindValue(':id', $_GET['id']); $post = $command->query(); ~~~ For more information about how to perform various DB queries, please refer to Command. If the underlying DBMS supports transactions, you can perform transactional SQL queries like the following: ~~~ $transaction = $connection->beginTransaction(); try { $connection->createCommand($sql1)->execute(); $connection->createCommand($sql2)->execute(); ... executing other SQL statements ... $transaction->commit(); } catch (Exception $e) { $transaction->rollBack(); } ~~~ You also can use shortcut for the above like the following: ~~~ $connection->transaction(function() { $order = new Order($customer); $order->save(); $order->addItems($items); }); ~~~ If needed you can pass transaction isolation level as a second parameter: ~~~ $connection->transaction(function(Connection $db) { return $db->... }, Transaction::READ_UNCOMMITTED); ~~~ Connection is often used as an application component and configured in the application configuration like the following: ~~~ 'components' => [ 'db' => [ 'class' => '\yii\db\Connection', 'dsn' => 'mysql:host=127.0.0.1;dbname=demo', 'username' => 'root', 'password' => '', 'charset' => 'utf8', ], ], ~~~
부터: 2.0
저자: Qiang Xue ([email protected])
상속: extends yii\base\Component
파일 보기 프로젝트 열기: yiisoft/yii2 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$attributes PDO attributes (name => value) that should be set when calling Connection::open to establish a DB connection. Please refer to the PHP manual for details about available attributes.
$charset the charset used for database connection. The property is only used for MySQL, PostgreSQL and CUBRID databases. Defaults to null, meaning using default charset as configured by the database. For Oracle Database, the charset must be specified in the [[dsn]], for example for UTF-8 by appending ;charset=UTF-8 to the DSN string. The same applies for if you're using GBK or BIG5 charset with MySQL, then it's highly recommended to specify charset via [[dsn]] like 'mysql:dbname=mydatabase;host=127.0.0.1;charset=GBK;'.
$commandClass the class used to create new database Command objects. If you want to extend the Command class, you may configure this property to use your extended version of the class.
$dsn the Data Source Name, or DSN, contains the information required to connect to the database. Please refer to the PHP manual on the format of the DSN string. For SQLite you may use a path alias for specifying the database path, e.g. sqlite:@app/data/db.sql.
$emulatePrepare whether to turn on prepare emulation. Defaults to false, meaning PDO will use the native prepare support if available. For some databases (such as MySQL), this may need to be set true so that PDO can emulate the prepare support to bypass the buggy native prepare support. The default value is null, which means the PDO ATTR_EMULATE_PREPARES value will not be changed.
$enableQueryCache whether to enable query caching. Note that in order to enable query caching, a valid cache component as specified by [[queryCache]] must be enabled and [[enableQueryCache]] must be set true. Also, only the results of the queries enclosed within Connection::cache will be cached.
$enableSavepoint whether to enable savepoint. Note that if the underlying DBMS does not support savepoint, setting this property to be true will have no effect.
$enableSchemaCache whether to enable schema caching. Note that in order to enable truly schema caching, a valid cache component as specified by [[schemaCache]] must be enabled and [[enableSchemaCache]] must be set true.
$enableSlaves whether to enable read/write splitting by using [[slaves]] to read data. Note that if [[slaves]] is empty, read/write splitting will NOT be enabled no matter what value this property takes.
$masterConfig the configuration that should be merged with every master configuration listed in [[masters]]. For example, php [ 'username' => 'master', 'password' => 'master', 'attributes' => [ use a smaller connection timeout PDO::ATTR_TIMEOUT => 10, ], ]
$masters list of master connection configurations. Each configuration is used to create a master DB connection. When Connection::open is called, one of these configurations will be chosen and used to create a DB connection which will be used by this object. Note that when this property is not empty, the connection setting (e.g. "dsn", "username") of this object will be ignored.
$password the password for establishing DB connection. Defaults to null meaning no password to use.
$pdo the PHP PDO instance associated with this DB connection. This property is mainly managed by Connection::open and Connection::close methods. When a DB connection is active, this property will represent a PDO instance; otherwise, it will be null.
$pdoClass Custom PDO wrapper class. If not set, it will use [[PDO]] or PDO when MSSQL is used.
$queryCache the cache object or the ID of the cache application component that is used for query caching.
$queryCacheDuration the default number of seconds that query results can remain valid in cache. Defaults to 3600, meaning 3600 seconds, or one hour. Use 0 to indicate that the cached data will never expire. The value of this property will be used when Connection::cache is called without a cache duration.
$schemaCache the cache object or the ID of the cache application component that is used to cache the table metadata.
$schemaCacheDuration number of seconds that table metadata can remain valid in cache. Use 0 to indicate that the cached data will never expire.
$schemaCacheExclude list of tables whose metadata should NOT be cached. Defaults to empty array. The table names may contain schema prefix, if any. Do not quote the table names.
$schemaMap mapping between PDO driver names and Schema classes. The keys of the array are PDO driver names while the values the corresponding schema class name or configuration. Please refer to [[Yii::createObject()]] for details on how to specify a configuration. This property is mainly used by Connection::getSchema when fetching the database schema information. You normally do not need to set this property unless you want to use your own Schema class to support DBMS that is not supported by Yii.
$serverRetryInterval the retry interval in seconds for dead servers listed in [[masters]] and [[slaves]]. This is used together with [[serverStatusCache]].
$serverStatusCache the cache object or the ID of the cache application component that is used to store the health status of the DB servers specified in [[masters]] and [[slaves]]. This is used only when read/write splitting is enabled or [[masters]] is not empty.
$slaveConfig the configuration that should be merged with every slave configuration listed in [[slaves]]. For example, php [ 'username' => 'slave', 'password' => 'slave', 'attributes' => [ use a smaller connection timeout PDO::ATTR_TIMEOUT => 10, ], ]
$slaves list of slave connection configurations. Each configuration is used to create a slave DB connection. When [[enableSlaves]] is true, one of these configurations will be chosen and used to create a DB connection for performing read queries only.
$tablePrefix 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}}.
$username the username for establishing DB connection. Defaults to null meaning no username to use.

공개 메소드들

메소드 설명
__sleep ( ) : array Close the connection before serializing.
beginTransaction ( string | null $isolationLevel = null ) : Transaction Starts a transaction.
cache ( callable $callable, integer $duration = null, yii\caching\Dependency $dependency = null ) : mixed Uses query cache for the queries performed with the callable.
close ( ) Closes the currently active DB connection.
createCommand ( string $sql = null, array $params = [] ) : Command Creates a command for execution.
getDriverName ( ) : string Returns the name of the DB driver. Based on the the current [[dsn]], in case it was not set explicitly by an end user.
getIsActive ( ) : boolean Returns a value indicating whether the DB connection is established.
getLastInsertID ( string $sequenceName = '' ) : string Returns the ID of the last inserted row or sequence value.
getMasterPdo ( ) : PDO Returns the PDO instance for the currently active master connection.
getQueryBuilder ( ) : QueryBuilder Returns the query builder for the current DB connection.
getQueryCacheInfo ( integer $duration, yii\caching\Dependency $dependency ) : array Returns the current query cache information.
getSchema ( ) : Schema Returns the schema information for the database opened by this connection.
getSlave ( boolean $fallbackToMaster = true ) : Connection Returns the currently active slave connection.
getSlavePdo ( boolean $fallbackToMaster = true ) : PDO Returns the PDO instance for the currently active slave connection.
getTableSchema ( string $name, boolean $refresh = false ) : yii\db\TableSchema Obtains the schema information for the named table.
getTransaction ( ) : Transaction Returns the currently active transaction.
noCache ( callable $callable ) : mixed Disables query cache temporarily.
open ( ) Establishes a DB connection.
quoteColumnName ( string $name ) : string Quotes a column name for use in a query.
quoteSql ( string $sql ) : string Processes a SQL statement by quoting table and column names that are enclosed within double brackets.
quoteTableName ( string $name ) : string Quotes a table name for use in a query.
quoteValue ( string $value ) : string Quotes a string value for use in a query.
setDriverName ( string $driverName ) Changes the current driver name.
transaction ( callable $callback, string | null $isolationLevel = null ) : mixed Executes callback provided in a transaction.
useMaster ( callable $callback ) : mixed Executes the provided callback by using the master connection.

보호된 메소드들

메소드 설명
createPdoInstance ( ) : PDO Creates the PDO instance.
initConnection ( ) Initializes the DB connection.
openFromPool ( array $pool, array $sharedConfig ) : Connection Opens the connection to a server in the pool.

메소드 상세

__sleep() 공개 메소드

Close the connection before serializing.
public __sleep ( ) : array
리턴 array

beginTransaction() 공개 메소드

Starts a transaction.
public beginTransaction ( string | null $isolationLevel = null ) : Transaction
$isolationLevel string | null The isolation level to use for this transaction. See [[Transaction::begin()]] for details.
리턴 Transaction the transaction initiated

cache() 공개 메소드

When query caching is enabled ([[enableQueryCache]] is true and [[queryCache]] refers to a valid cache), queries performed within the callable will be cached and their results will be fetched from cache if available. For example, php The customer will be fetched from cache if available. If not, the query will be made against DB and cached for use next time. $customer = $db->cache(function (Connection $db) { return $db->createCommand('SELECT * FROM customer WHERE id=1')->queryOne(); }); Note that query cache is only meaningful for queries that return results. For queries performed with [[Command::execute()]], query cache will not be used.
또한 보기: enableQueryCache
또한 보기: queryCache
또한 보기: noCache()
public cache ( callable $callable, integer $duration = null, yii\caching\Dependency $dependency = null ) : mixed
$callable callable a PHP callable that contains DB queries which will make use of query cache. The signature of the callable is `function (Connection $db)`.
$duration integer the number of seconds that query results can remain valid in the cache. If this is not set, the value of [[queryCacheDuration]] will be used instead. Use 0 to indicate that the cached data will never expire.
$dependency yii\caching\Dependency the cache dependency associated with the cached query results.
리턴 mixed the return result of the callable

close() 공개 메소드

It does nothing if the connection is already closed.
public close ( )

createCommand() 공개 메소드

Creates a command for execution.
public createCommand ( string $sql = null, array $params = [] ) : Command
$sql string the SQL statement to be executed
$params array the parameters to be bound to the SQL statement
리턴 Command the DB command

createPdoInstance() 보호된 메소드

This method is called by [[open]] to establish a DB connection. The default implementation will create a PHP PDO instance. You may override this method if the default PDO needs to be adapted for certain DBMS.
protected createPdoInstance ( ) : PDO
리턴 PDO the pdo instance

getDriverName() 공개 메소드

Returns the name of the DB driver. Based on the the current [[dsn]], in case it was not set explicitly by an end user.
public getDriverName ( ) : string
리턴 string name of the DB driver

getIsActive() 공개 메소드

Returns a value indicating whether the DB connection is established.
public getIsActive ( ) : boolean
리턴 boolean whether the DB connection is established

getLastInsertID() 공개 메소드

Returns the ID of the last inserted row or sequence value.
또한 보기: http://www.php.net/manual/en/function.PDO-lastInsertId.php
public getLastInsertID ( string $sequenceName = '' ) : string
$sequenceName string name of the sequence object (required by some DBMS)
리턴 string the row ID of the last row inserted, or the last value retrieved from the sequence object

getMasterPdo() 공개 메소드

This method will open the master DB connection and then return [[pdo]].
public getMasterPdo ( ) : PDO
리턴 PDO the PDO instance for the currently active master connection.

getQueryBuilder() 공개 메소드

Returns the query builder for the current DB connection.
public getQueryBuilder ( ) : QueryBuilder
리턴 QueryBuilder the query builder for the current DB connection.

getQueryCacheInfo() 공개 메소드

This method is used internally by Command.
public getQueryCacheInfo ( integer $duration, yii\caching\Dependency $dependency ) : array
$duration integer the preferred caching duration. If null, it will be ignored.
$dependency yii\caching\Dependency the preferred caching dependency. If null, it will be ignored.
리턴 array the current query cache information, or null if query cache is not enabled.

getSchema() 공개 메소드

Returns the schema information for the database opened by this connection.
public getSchema ( ) : Schema
리턴 Schema the schema information for the database opened by this connection.

getSlave() 공개 메소드

If this method is called the first time, it will try to open a slave connection when [[enableSlaves]] is true.
public getSlave ( boolean $fallbackToMaster = true ) : Connection
$fallbackToMaster boolean whether to return a master connection in case there is no slave connection available.
리턴 Connection the currently active slave connection. Null is returned if there is slave available and `$fallbackToMaster` is false.

getSlavePdo() 공개 메소드

When [[enableSlaves]] is true, one of the slaves will be used for read queries, and its PDO instance will be returned by this method.
public getSlavePdo ( boolean $fallbackToMaster = true ) : PDO
$fallbackToMaster boolean whether to return a master PDO in case none of the slave connections is available.
리턴 PDO the PDO instance for the currently active slave connection. Null is returned if no slave connection is available and `$fallbackToMaster` is false.

getTableSchema() 공개 메소드

Obtains the schema information for the named table.
public getTableSchema ( string $name, boolean $refresh = false ) : yii\db\TableSchema
$name string table name.
$refresh boolean whether to reload the table schema even if it is found in the cache.
리턴 yii\db\TableSchema table schema information. Null if the named table does not exist.

getTransaction() 공개 메소드

Returns the currently active transaction.
public getTransaction ( ) : Transaction
리턴 Transaction the currently active transaction. Null if no active transaction.

initConnection() 보호된 메소드

This method is invoked right after the DB connection is established. The default implementation turns on PDO::ATTR_EMULATE_PREPARES if [[emulatePrepare]] is true, and sets the database [[charset]] if it is not empty. It then triggers an [[EVENT_AFTER_OPEN]] event.
protected initConnection ( )

noCache() 공개 메소드

Queries performed within the callable will not use query cache at all. For example, php $db->cache(function (Connection $db) { ... queries that use query cache ... return $db->noCache(function (Connection $db) { this query will not use query cache return $db->createCommand('SELECT * FROM customer WHERE id=1')->queryOne(); }); });
또한 보기: enableQueryCache
또한 보기: queryCache
또한 보기: cache()
public noCache ( callable $callable ) : mixed
$callable callable a PHP callable that contains DB queries which should not use query cache. The signature of the callable is `function (Connection $db)`.
리턴 mixed the return result of the callable

open() 공개 메소드

It does nothing if a DB connection has already been established.
public open ( )

openFromPool() 보호된 메소드

This method implements the load balancing among the given list of the servers.
protected openFromPool ( array $pool, array $sharedConfig ) : Connection
$pool array the list of connection configurations in the server pool
$sharedConfig array the configuration common to those given in `$pool`.
리턴 Connection the opened DB connection, or null if no server is available

quoteColumnName() 공개 메소드

If the column name contains prefix, the prefix will also be properly quoted. If the column name is already quoted or contains special characters including '(', '[[' and '{{', then this method will do nothing.
public quoteColumnName ( string $name ) : string
$name string column name
리턴 string the properly quoted column name

quoteSql() 공개 메소드

Tokens enclosed within double curly brackets are treated as table names, while tokens enclosed within double square brackets are column names. They will be quoted accordingly. Also, the percentage character "%" at the beginning or ending of a table name will be replaced with [[tablePrefix]].
public quoteSql ( string $sql ) : string
$sql string the SQL to be quoted
리턴 string the quoted SQL

quoteTableName() 공개 메소드

If the table name contains schema prefix, the prefix will also be properly quoted. If the table name is already quoted or contains special characters including '(', '[[' and '{{', then this method will do nothing.
public quoteTableName ( string $name ) : string
$name string table name
리턴 string the properly quoted table name

quoteValue() 공개 메소드

Note that if the parameter is not a string, it will be returned without change.
또한 보기: http://www.php.net/manual/en/function.PDO-quote.php
public quoteValue ( string $value ) : string
$value string string to be quoted
리턴 string the properly quoted string

setDriverName() 공개 메소드

Changes the current driver name.
public setDriverName ( string $driverName )
$driverName string name of the DB driver

transaction() 공개 메소드

Executes callback provided in a transaction.
public transaction ( callable $callback, string | null $isolationLevel = null ) : mixed
$callback callable a valid PHP callback that performs the job. Accepts connection instance as parameter.
$isolationLevel string | null The isolation level to use for this transaction. See [[Transaction::begin()]] for details.
리턴 mixed result of callback function

useMaster() 공개 메소드

This method is provided so that you can temporarily force using the master connection to perform DB operations even if they are read queries. For example, php $result = $db->useMaster(function ($db) { return $db->createCommand('SELECT * FROM user LIMIT 1')->queryOne(); });
public useMaster ( callable $callback ) : mixed
$callback callable a PHP callable to be executed by this method. Its signature is `function (Connection $db)`. Its return value will be returned by this method.
리턴 mixed the return value of the callback

프로퍼티 상세

$attributes 공개적으로 프로퍼티

PDO attributes (name => value) that should be set when calling Connection::open to establish a DB connection. Please refer to the PHP manual for details about available attributes.
public $attributes

$charset 공개적으로 프로퍼티

the charset used for database connection. The property is only used for MySQL, PostgreSQL and CUBRID databases. Defaults to null, meaning using default charset as configured by the database. For Oracle Database, the charset must be specified in the [[dsn]], for example for UTF-8 by appending ;charset=UTF-8 to the DSN string. The same applies for if you're using GBK or BIG5 charset with MySQL, then it's highly recommended to specify charset via [[dsn]] like 'mysql:dbname=mydatabase;host=127.0.0.1;charset=GBK;'.
public $charset

$commandClass 공개적으로 프로퍼티

the class used to create new database Command objects. If you want to extend the Command class, you may configure this property to use your extended version of the class.
또한 보기: createCommand
부터: 2.0.7
public $commandClass

$dsn 공개적으로 프로퍼티

the Data Source Name, or DSN, contains the information required to connect to the database. Please refer to the PHP manual on the format of the DSN string. For SQLite you may use a path alias for specifying the database path, e.g. sqlite:@app/data/db.sql.
또한 보기: charset
public $dsn

$emulatePrepare 공개적으로 프로퍼티

whether to turn on prepare emulation. Defaults to false, meaning PDO will use the native prepare support if available. For some databases (such as MySQL), this may need to be set true so that PDO can emulate the prepare support to bypass the buggy native prepare support. The default value is null, which means the PDO ATTR_EMULATE_PREPARES value will not be changed.
public $emulatePrepare

$enableQueryCache 공개적으로 프로퍼티

whether to enable query caching. Note that in order to enable query caching, a valid cache component as specified by [[queryCache]] must be enabled and [[enableQueryCache]] must be set true. Also, only the results of the queries enclosed within Connection::cache will be cached.
또한 보기: queryCache
또한 보기: cache()
또한 보기: noCache()
public $enableQueryCache

$enableSavepoint 공개적으로 프로퍼티

whether to enable savepoint. Note that if the underlying DBMS does not support savepoint, setting this property to be true will have no effect.
public $enableSavepoint

$enableSchemaCache 공개적으로 프로퍼티

whether to enable schema caching. Note that in order to enable truly schema caching, a valid cache component as specified by [[schemaCache]] must be enabled and [[enableSchemaCache]] must be set true.
또한 보기: schemaCacheDuration
또한 보기: schemaCacheExclude
또한 보기: schemaCache
public $enableSchemaCache

$enableSlaves 공개적으로 프로퍼티

whether to enable read/write splitting by using [[slaves]] to read data. Note that if [[slaves]] is empty, read/write splitting will NOT be enabled no matter what value this property takes.
public $enableSlaves

$masterConfig 공개적으로 프로퍼티

the configuration that should be merged with every master configuration listed in [[masters]]. For example, php [ 'username' => 'master', 'password' => 'master', 'attributes' => [ use a smaller connection timeout PDO::ATTR_TIMEOUT => 10, ], ]
public $masterConfig

$masters 공개적으로 프로퍼티

list of master connection configurations. Each configuration is used to create a master DB connection. When Connection::open is called, one of these configurations will be chosen and used to create a DB connection which will be used by this object. Note that when this property is not empty, the connection setting (e.g. "dsn", "username") of this object will be ignored.
또한 보기: masterConfig
public $masters

$password 공개적으로 프로퍼티

the password for establishing DB connection. Defaults to null meaning no password to use.
public $password

$pdo 공개적으로 프로퍼티

the PHP PDO instance associated with this DB connection. This property is mainly managed by Connection::open and Connection::close methods. When a DB connection is active, this property will represent a PDO instance; otherwise, it will be null.
또한 보기: pdoClass
public $pdo

$pdoClass 공개적으로 프로퍼티

Custom PDO wrapper class. If not set, it will use [[PDO]] or PDO when MSSQL is used.
또한 보기: pdo
public $pdoClass

$queryCache 공개적으로 프로퍼티

the cache object or the ID of the cache application component that is used for query caching.
또한 보기: enableQueryCache
public $queryCache

$queryCacheDuration 공개적으로 프로퍼티

the default number of seconds that query results can remain valid in cache. Defaults to 3600, meaning 3600 seconds, or one hour. Use 0 to indicate that the cached data will never expire. The value of this property will be used when Connection::cache is called without a cache duration.
또한 보기: enableQueryCache
또한 보기: cache()
public $queryCacheDuration

$schemaCache 공개적으로 프로퍼티

the cache object or the ID of the cache application component that is used to cache the table metadata.
또한 보기: enableSchemaCache
public $schemaCache

$schemaCacheDuration 공개적으로 프로퍼티

number of seconds that table metadata can remain valid in cache. Use 0 to indicate that the cached data will never expire.
또한 보기: enableSchemaCache
public $schemaCacheDuration

$schemaCacheExclude 공개적으로 프로퍼티

list of tables whose metadata should NOT be cached. Defaults to empty array. The table names may contain schema prefix, if any. Do not quote the table names.
또한 보기: enableSchemaCache
public $schemaCacheExclude

$schemaMap 공개적으로 프로퍼티

mapping between PDO driver names and Schema classes. The keys of the array are PDO driver names while the values the corresponding schema class name or configuration. Please refer to [[Yii::createObject()]] for details on how to specify a configuration. This property is mainly used by Connection::getSchema when fetching the database schema information. You normally do not need to set this property unless you want to use your own Schema class to support DBMS that is not supported by Yii.
public $schemaMap

$serverRetryInterval 공개적으로 프로퍼티

the retry interval in seconds for dead servers listed in [[masters]] and [[slaves]]. This is used together with [[serverStatusCache]].
public $serverRetryInterval

$serverStatusCache 공개적으로 프로퍼티

the cache object or the ID of the cache application component that is used to store the health status of the DB servers specified in [[masters]] and [[slaves]]. This is used only when read/write splitting is enabled or [[masters]] is not empty.
public $serverStatusCache

$slaveConfig 공개적으로 프로퍼티

the configuration that should be merged with every slave configuration listed in [[slaves]]. For example, php [ 'username' => 'slave', 'password' => 'slave', 'attributes' => [ use a smaller connection timeout PDO::ATTR_TIMEOUT => 10, ], ]
public $slaveConfig

$slaves 공개적으로 프로퍼티

list of slave connection configurations. Each configuration is used to create a slave DB connection. When [[enableSlaves]] is true, one of these configurations will be chosen and used to create a DB connection for performing read queries only.
또한 보기: enableSlaves
또한 보기: slaveConfig
public $slaves

$tablePrefix 공개적으로 프로퍼티

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}}.
public $tablePrefix

$username 공개적으로 프로퍼티

the username for establishing DB connection. Defaults to null meaning no username to use.
public $username