VirtualConnection
class VirtualConnection implements VirtualConnectionInterface
VirtualConnection
- config/xe.php 의 설정에 따라 Illuminate\Database\Connection 관리
- select query 할 경우 slave 설정의 connection 반환
- Illuminate\Database\Connection 의 wrapper class
- Database 의 Proxy 를 처리하기위해 DynamicQuery 사용
사용
Database Connection
$connector = app('xe.db');
$connection = $connector->master();
$connection = $connector->slave();
Query
$connector = app('xe.db');
$query = $connector->table('user');
$result = $connector->table('user')->first();
$proxyConfig = [... config for proxy ...];
$query = $connector->dynamic('tableName', $proxyConfig);
Constants
TYPE_MASTER |
master type key name |
TYPE_SLAVE |
slave type key name |
DEFAULT_CONNECTION_NAME |
default database connection name (config/database.php 의 기본 connection 설정 이름) |
Properties
protected DatabaseCoupler | $coupler | ||
protected DynamicQuery | $queryBuilder | ||
protected string | $name | connector name | |
protected string | $master | config/database.php config name for create master connection instance | |
protected string | $slave | config/database.php config name for create slave connection instance | |
protected string | $tablePrefix | ||
protected array | $connections | connections list
|
|
protected int | $fetchMode | The default fetch mode of the connection. | |
static protected Repository | $cache | Cache store instance | |
protected int | $minutes | The number of minutes to store cache items. |
Methods
Get the default fetch mode for the connection.
Set the default fetch mode for the connection.
get name for connector
DynamicQuery 에서 사용 \Illuminate\Database\Query\Builder 를 만들 때 Connection 이 필요함.
Get a schema builder instance for the connection.
Get table prefix name.
set connection name.
설정 정보 확인 master, slave 설정이 없을 경우 기본 설정을 넣어 줌
$type 에서 사용 될 connection name 결정.
get ProxyManager.
get connection
get master connection
get slave connection
get connection by $queryType.
Begin a fluent query against a database table.
DynamicField 를 이용해 처리.
Get a new query builder instance.
Get a new raw query expression.
Run a select statement and return a single result.
Run a select statement against the database.
Run an insert statement against the database.
Run an update statement against the database.
Run a delete statement against the database.
Execute an SQL statement and return the boolean result.
Run an SQL statement and get the number of rows affected.
Run a raw, unprepared query against the PDO connection.
Prepare the query bindings for execution.
get TransactionHandler
Start a new database transaction.
Commit the active database transaction.
Rollback the active database transaction.
Get the number of active transactions.
return database table schema
set database table schema
Set the cache store.
Get the cache store.
Set the number of minutes to store cache items.
인터페이스에 정의되지 않은 기능을 수행 하기 위함.
Details
at line 156
__construct(DatabaseCoupler $coupler, string $name, array $config)
Create instance
at line 168
int
getFetchMode()
Get the default fetch mode for the connection.
at line 180
int
setFetchMode(int $fetchMode)
Set the default fetch mode for the connection.
at line 190
string
getName()
get name for connector
at line 201
Connection
getDefaultConnection()
DynamicQuery 에서 사용 \Illuminate\Database\Query\Builder 를 만들 때 Connection 이 필요함.
at line 211
Builder
getSchemaBuilder()
Get a schema builder instance for the connection.
at line 221
string
getTablePrefix()
Get table prefix name.
at line 233
private void
setNames(array $config)
set connection name.
설정된 master, slave 이름들에서 사용 할 이름을 선택.
at line 247
private mixed
fixConfig(array $config)
설정 정보 확인 master, slave 설정이 없을 경우 기본 설정을 넣어 줌
at line 266
private Connection
connectionName(array $names)
$type 에서 사용 될 connection name 결정.
at line 278
ProxyManager
getProxyManager()
get ProxyManager.
DynamicQuery 에서 VirtualConnection 를 주입 받아 사용.
at line 289
Connection
connection(string $type = self::DEFAULT_CONNECTION_NAME)
get connection
at line 303
Connection
master()
get master connection
at line 313
Connection
slave()
get slave connection
at line 326
ConnectionInterface
getConnection(string $type = 'select')
get connection by $queryType.
'select' 쿼리일 경우 $slaveConnection 을 넘겨주고 그렇지 않을 경우 $masterConnection 을 반환. database 를 쿼리 실행 시 연결.
at line 342
DynamicQuery
table(string $table)
Begin a fluent query against a database table.
ProxyManager 를 통한 처리를 하지 않음.
at line 356
DynamicQuery
dynamic(string $table, array $options = array(), bool $proxy = true)
DynamicField 를 이용해 처리.
ProxyManager 에 register 된 Proxy 들을 처리.
at line 374
DynamicQuery
query()
Get a new query builder instance.
at line 386
Expression
raw(mixed $value)
Get a new raw query expression.
at line 398
mixed
selectOne(string $query, array $bindings = array())
Run a select statement and return a single result.
at line 410
array
select(string $query, array $bindings = array())
Run a select statement against the database.
at line 422
bool
insert(string $query, array $bindings = array())
Run an insert statement against the database.
at line 434
int
update(string $query, array $bindings = array())
Run an update statement against the database.
at line 446
int
delete(string $query, array $bindings = array())
Run a delete statement against the database.
at line 458
bool
statement(string $query, array $bindings = array())
Execute an SQL statement and return the boolean result.
at line 470
int
affectingStatement(string $query, array $bindings = array())
Run an SQL statement and get the number of rows affected.
at line 481
bool
unprepared(string $query)
Run a raw, unprepared query against the PDO connection.
at line 492
array
prepareBindings(array $bindings)
Prepare the query bindings for execution.
at line 505
mixed
transaction(Closure $callback)
Execute a Closure within a transaction.
at line 531
TransactionHandler
transactionHandler()
get TransactionHandler
at line 541
void
beginTransaction()
Start a new database transaction.
DatabaseHandler 를 통해서 transaction 관리.
at line 552
void
commit()
Commit the active database transaction.
DatabaseHandler 를 통해서 commit.
at line 562
void
rollBack()
Rollback the active database transaction.
at line 572
int
transactionLevel()
Get the number of active transactions.
at line 583
array
pretend(Closure $callback)
Execute the given callback in "dry run" mode.
at line 594
array
getSchema(string $table)
return database table schema
at line 614
bool
setSchemaCache(string $table, bool $force = false)
set database table schema
at line 637
static void
setCache(Repository $cache)
Set the cache store.
at line 647
static Repository|null
getCache()
Get the cache store.
at line 658
void
setCacheExpire(int $minutes)
Set the number of minutes to store cache items.
at line 671
mixed
__call(string $method, array $parameters)
인터페이스에 정의되지 않은 기능을 수행 하기 위함.
Illuminate\Database\Connection 의 method 실행.