SQLServer
class SQLServer extends Connection
SQLServer database connection.
Properties
protected string | $name | Connection name. | from Connection |
protected string. | $queryCompiler | Query compiler. | from Connection |
protected string | $queryBuilderHelper | Query builder helper. | from Connection |
protected string | $dsn | Connection DSN. | from Connection |
protected string | $username | Database username. | from Connection |
protected string | $password | Database password. | from Connection |
protected bool | $enableLog | Enable the query log? | from Connection |
protected bool | $reconnect | Should we reconnect? | from Connection |
protected bool | $usePersistentConnection | Should we use a persistent connection? | from Connection |
protected array | $options | PDO options. | from Connection |
protected array | $onConnectQueries | Queries that should be executed upon connecting. | from Connection |
protected PDO | $pdo | PDO object. | from Connection |
protected int | $transactionNestingLevel | Transaction nesting level. | from Connection |
protected array | $log | Query log. | from Connection |
protected bool | $supportsTransactionalDDL | Does the connection support transactional DDL? | from Connection |
Methods
Constructor.
Should we try to reestablish the connection?
Binds parameter to the prepared statement.
Prepares and executes a query.
Executes the query and returns TRUE on success or FALSE on failure.
Executes the query and return number of affected rows.
Returns the first row of the result set.
Returns an array containing all of the result set rows.
Returns the value of the first column of the first row of the result set.
Returns an array containing the values of the indicated 0-indexed column.
Returns an array where the first column is used as keys and the second as values.
Returns a generator that lets you iterate over the results.
Returns a query builder instance where we have already chosen the table we want to query.
Creates a new savepoint.
Rolls back to the previously created savepoint.
Details
in Connection at line 161
__construct(string $name, string $queryCompiler, string $queryBuilderHelper, array $config)
Constructor.
in Connection at line 197
close()
Closes the database connection.
in Connection at line 207
bool
supportsTransactionalDDL()
Does the connection support transactional DDL?
in Connection at line 217
string
getName()
Returns the connection name.
in Connection at line 227
HelperInterface
getQueryBuilderHelper()
Returns a query builder helper instance.
in Connection at line 240
Compiler
getQueryCompiler(Query $query)
Returns a query compiler instance.
in Connection at line 252
PDO
getPDO()
Returns the PDO instance.
in Connection at line 260
enableLog()
Enables the query log.
in Connection at line 268
disableLog()
Disables the query log.
in Connection at line 278
protected array
getConnectionOptions()
Returns the connection options.
in Connection at line 296
protected PDO
connect()
Creates a PDO instance.
in Connection at line 324
reconnect()
Creates a new PDO instance.
in Connection at line 334
bool
isAlive()
Checks if the connection is alive.
in Connection at line 355
protected string
prepareQueryForLog(string $query, array $params)
Prepares query for logging.
in Connection at line 395
protected
log(string $query, array $params, float $start)
Adds a query to the query log.
in Connection at line 407
clearLog()
Clears the query log.
in Connection at line 417
array
getLog()
Returns the query log for the connection.
in Connection at line 429
protected array
prepareQueryAndParams(string $query, array $params)
Prepare query and params.
in Connection at line 460
protected bool
isConnectionLostAndShouldItBeReestablished()
Should we try to reestablish the connection?
in Connection at line 472
protected
bindParameter(PDOStatement $statement, int $key, mixed $value)
Binds parameter to the prepared statement.
in Connection at line 517
protected PDOStatement
prepareAndExecute(string $query, array $params, bool $success = null)
Prepares and executes a query.
in Connection at line 574
bool
query(string $query, array $params = [])
Executes the query and returns TRUE on success or FALSE on failure.
in Connection at line 588
int
queryAndCount(string $query, array $params = [])
Executes the query and return number of affected rows.
in Connection at line 601
mixed|bool
first(string $query, array $params = [], mixed ...$fetchMode)
Returns the first row of the result set.
in Connection at line 621
array
all(string $query, array $params = [], mixed ...$fetchMode)
Returns an array containing all of the result set rows.
in Connection at line 633
mixed|bool
column(string $query, array $params = [])
Returns the value of the first column of the first row of the result set.
in Connection at line 645
array
columns(string $query, array $params = [])
Returns an array containing the values of the indicated 0-indexed column.
in Connection at line 657
array
pairs(string $query, array $params = [])
Returns an array where the first column is used as keys and the second as values.
in Connection at line 670
Generator
yield(string $query, array $params = [], mixed ...$fetchMode)
Returns a generator that lets you iterate over the results.
in Connection at line 697
Query
builder()
Returns a query builder instance.
in Connection at line 708
Query
table(null|string|Closure|Subquery|Raw $table)
Returns a query builder instance where we have already chosen the table we want to query.
at line 20
protected bool
createSavepoint()
Creates a new savepoint.
at line 28
protected bool
rollBackSavepoint()
Rolls back to the previously created savepoint.
in Connection at line 738
bool
beginTransaction()
Begin a transaction.
in Connection at line 753
bool
commitTransaction()
Commits a transaction.
in Connection at line 768
bool
rollBackTransaction()
Roll back a transaction.
in Connection at line 794
int
getTransactionNestingLevel()
Returns the transaction nesting level.
in Connection at line 804
bool
inTransaction()
Returns TRUE if we're in a transaction and FALSE if not.
in Connection at line 816
mixed
transaction(Closure $queries)
Executes queries and rolls back the transaction if any of them fail.