0 follower

Interface Yiisoft\Db\Driver\Pdo\PdoConnectionInterface

ExtendsYiisoft\Db\Connection\ConnectionInterface
Implemented byYiisoft\Db\Driver\Pdo\AbstractPdoConnection

This interface defines a set of methods to implement in a class that allows to connect to a database with {@see PDO} (PHP Data Objects).

Public Methods

Hide inherited methods

Method Description Defined By
beginTransaction() Starts a transaction. Yiisoft\Db\Connection\ConnectionInterface
close() Closes the currently active DB connection. Yiisoft\Db\Connection\ConnectionInterface
createBatchQueryResult() Create a batch query result instance. Yiisoft\Db\Connection\ConnectionInterface
createCommand() Creates a command for execution. Yiisoft\Db\Connection\ConnectionInterface
createQuery() Creates a query instance. Yiisoft\Db\Connection\ConnectionInterface
createTransaction() Create a transaction instance. Yiisoft\Db\Connection\ConnectionInterface
getActivePdo() Returns the PDO instance for the current connection. Yiisoft\Db\Driver\Pdo\PdoConnectionInterface
getColumnBuilderClass() Returns the column builder class name for the current DB connection. Yiisoft\Db\Connection\ConnectionInterface
getColumnFactory() Returns the column factory for creating column instances. Yiisoft\Db\Connection\ConnectionInterface
getDriver() Returns current DB driver. Yiisoft\Db\Driver\Pdo\PdoConnectionInterface
getDriverName() Returns the name of the DB driver for the current dsn. Yiisoft\Db\Connection\ConnectionInterface
getEmulatePrepare() Whether to emulate prepared statements on PHP side. Yiisoft\Db\Driver\Pdo\PdoConnectionInterface
getLastInsertId() Returns the ID of the last inserted row or sequence value. Yiisoft\Db\Connection\ConnectionInterface
getPdo() The PHP {@see PDO} instance associated with this DB connection. Yiisoft\Db\Driver\Pdo\PdoConnectionInterface
getQueryBuilder() Returns the query builder for the current DB connection. Yiisoft\Db\Connection\ConnectionInterface
getQuoter() Return quoter helper for current DB connection. Yiisoft\Db\Connection\ConnectionInterface
getSchema() Returns the schema information for the database opened by this connection. Yiisoft\Db\Connection\ConnectionInterface
getServerInfo() Returns {@see ServerInfoInterface} instance that provides information about the database server. Yiisoft\Db\Connection\ConnectionInterface
getTablePrefix() Return table prefix for current DB connection. Yiisoft\Db\Connection\ConnectionInterface
getTableSchema() Obtains the schema information for the named table. Yiisoft\Db\Connection\ConnectionInterface
getTransaction() Returns the currently active transaction. Yiisoft\Db\Connection\ConnectionInterface
isActive() Returns a value indicating whether the DB connection is active. Yiisoft\Db\Connection\ConnectionInterface
isSavepointEnabled() Yiisoft\Db\Connection\ConnectionInterface
open() Establishes a DB connection. Yiisoft\Db\Connection\ConnectionInterface
quoteValue() Quotes a value for use in a query. Yiisoft\Db\Connection\ConnectionInterface
select() Creates a new {@see Query} instance with the specified columns to be selected. Yiisoft\Db\Connection\ConnectionInterface
setEmulatePrepare() Whether to turn on prepare statements emulation on PHP side. Yiisoft\Db\Driver\Pdo\PdoConnectionInterface
setEnableSavepoint() Whether to enable savepoint. Yiisoft\Db\Connection\ConnectionInterface
setTablePrefix() The common prefix or suffix for table names. Yiisoft\Db\Connection\ConnectionInterface
transaction() Executes callback provided in a transaction. Yiisoft\Db\Connection\ConnectionInterface

Method Details

Hide inherited methods

beginTransaction() public abstract method
public abstract Yiisoft\Db\Transaction\TransactionInterface beginTransaction ( string|null $isolationLevel null )
$isolationLevel string|null

The isolation level to use for this transaction.

{@see \Yiisoft\Db\Transaction\TransactionInterface::begin()} for details.

return Yiisoft\Db\Transaction\TransactionInterface

The transaction initiated.

throws Yiisoft\Db\Exception\Exception
throws Yiisoft\Db\Exception\InvalidConfigException
throws Yiisoft\Db\Exception\NotSupportedException
throws Throwable

                public function beginTransaction(?string $isolationLevel = null): TransactionInterface;

            
close() public abstract method

Defined in: Yiisoft\Db\Connection\ConnectionInterface::close()

Closes the currently active DB connection.

It does nothing if the connection is already closed.

public abstract void close ( )

                public function close(): void;

            
createBatchQueryResult() public abstract method

Defined in: Yiisoft\Db\Connection\ConnectionInterface::createBatchQueryResult()

Create a batch query result instance.

public abstract Yiisoft\Db\Query\BatchQueryResultInterface createBatchQueryResult ( Yiisoft\Db\Query\QueryInterface $query )
$query Yiisoft\Db\Query\QueryInterface

The query to execute.

return Yiisoft\Db\Query\BatchQueryResultInterface

The batch query result instance.

                public function createBatchQueryResult(QueryInterface $query): BatchQueryResultInterface;

            
createCommand() public abstract method

Defined in: Yiisoft\Db\Connection\ConnectionInterface::createCommand()

Creates a command for execution.

public abstract Yiisoft\Db\Command\CommandInterface createCommand ( string|null $sql null, array $params = [] )
$sql string|null

The SQL statement to execute.

$params array

The parameters to bind to the SQL statement.

return Yiisoft\Db\Command\CommandInterface

The database command instance.

throws Yiisoft\Db\Exception\Exception
throws Yiisoft\Db\Exception\InvalidConfigException

                public function createCommand(?string $sql = null, array $params = []): CommandInterface;

            
createQuery() public abstract method

Defined in: Yiisoft\Db\Connection\ConnectionInterface::createQuery()

Creates a query instance.

public abstract Yiisoft\Db\Query\QueryInterface createQuery ( )
return Yiisoft\Db\Query\QueryInterface

The query instance.

                public function createQuery(): QueryInterface;

            
createTransaction() public abstract method

Defined in: Yiisoft\Db\Connection\ConnectionInterface::createTransaction()

Create a transaction instance.

public abstract Yiisoft\Db\Transaction\TransactionInterface createTransaction ( )
return Yiisoft\Db\Transaction\TransactionInterface

The transaction instance.

                public function createTransaction(): TransactionInterface;

            
getActivePdo() public abstract method

Returns the PDO instance for the current connection.

This method will open the DB connection and then return {@see \PDO}.

public abstract PDO getActivePdo ( )
return PDO

The {@see \PDO} instance for the current connection.

throws Yiisoft\Db\Exception\Exception
throws Yiisoft\Db\Exception\InvalidConfigException

                public function getActivePdo(): PDO;

            
getColumnBuilderClass() public abstract method

Defined in: Yiisoft\Db\Connection\ConnectionInterface::getColumnBuilderClass()

Returns the column builder class name for the current DB connection.

public abstract string getColumnBuilderClass ( )

                public function getColumnBuilderClass(): string;

            
getColumnFactory() public abstract method

Defined in: Yiisoft\Db\Connection\ConnectionInterface::getColumnFactory()

Returns the column factory for creating column instances.

public abstract Yiisoft\Db\Schema\Column\ColumnFactoryInterface getColumnFactory ( )

                public function getColumnFactory(): ColumnFactoryInterface;

            
getDriver() public abstract method

Returns current DB driver.

public abstract Yiisoft\Db\Driver\Pdo\PdoDriverInterface getDriver ( )
return Yiisoft\Db\Driver\Pdo\PdoDriverInterface

The driver used to create current connection.

                public function getDriver(): PdoDriverInterface;

            
getDriverName() public abstract method

Defined in: Yiisoft\Db\Connection\ConnectionInterface::getDriverName()

Returns the name of the DB driver for the current dsn.

Use this method for information only.

public abstract string getDriverName ( )
return string

The name of the DB driver for the current dsn.

                public function getDriverName(): string;

            
getEmulatePrepare() public abstract method

Whether to emulate prepared statements on PHP side.

See also setEmulatePrepare().

public abstract boolean|null getEmulatePrepare ( )

                public function getEmulatePrepare(): ?bool;

            
getLastInsertId() public abstract method

Defined in: Yiisoft\Db\Connection\ConnectionInterface::getLastInsertId()

Returns the ID of the last inserted row or sequence value.

public abstract string getLastInsertId ( string|null $sequenceName null )
$sequenceName string|null

The name of the sequence object (required by some DBMS).

return string

The row ID of the last row inserted, or the last value retrieved from the sequence object.

throws Yiisoft\Db\Exception\Exception
throws Yiisoft\Db\Exception\InvalidCallException

                public function getLastInsertId(?string $sequenceName = null): string;

            
getPdo() public abstract method

The PHP {@see PDO} instance associated with this DB connection.

This property is mainly managed by {@see \Yiisoft\Db\Driver\Pdo\open()} and {@see \Yiisoft\Db\Driver\Pdo\close()} methods.

When a DB connection is active, this property will represent a PDO instance. Otherwise, it will be null.

See also PDO.

public abstract PDO|null getPdo ( )
return PDO|null

The PHP PDO instance associated with this DB connection.

                public function getPdo(): ?PDO;

            
getQueryBuilder() public abstract method

Defined in: Yiisoft\Db\Connection\ConnectionInterface::getQueryBuilder()

Returns the query builder for the current DB connection.

public abstract Yiisoft\Db\QueryBuilder\QueryBuilderInterface getQueryBuilder ( )
return Yiisoft\Db\QueryBuilder\QueryBuilderInterface

The query builder for the current DB connection.

                public function getQueryBuilder(): QueryBuilderInterface;

            
getQuoter() public abstract method

Defined in: Yiisoft\Db\Connection\ConnectionInterface::getQuoter()

Return quoter helper for current DB connection.

public abstract Yiisoft\Db\Schema\QuoterInterface getQuoter ( )
return Yiisoft\Db\Schema\QuoterInterface

The quoter helper for the current DB connection.

                public function getQuoter(): QuoterInterface;

            
getSchema() public abstract method

Defined in: Yiisoft\Db\Connection\ConnectionInterface::getSchema()

Returns the schema information for the database opened by this connection.

public abstract Yiisoft\Db\Schema\SchemaInterface getSchema ( )
return Yiisoft\Db\Schema\SchemaInterface

The schema information for the database opened by this connection.

                public function getSchema(): SchemaInterface;

            
getServerInfo() public abstract method

Defined in: Yiisoft\Db\Connection\ConnectionInterface::getServerInfo()

Returns {@see ServerInfoInterface} instance that provides information about the database server.

public abstract Yiisoft\Db\Connection\ServerInfoInterface getServerInfo ( )

                public function getServerInfo(): ServerInfoInterface;

            
getTablePrefix() public abstract method

Defined in: Yiisoft\Db\Connection\ConnectionInterface::getTablePrefix()

Return table prefix for current DB connection.

public abstract string getTablePrefix ( )
return string

The table prefix for the current DB connection.

                public function getTablePrefix(): string;

            
getTableSchema() public abstract method

Defined in: Yiisoft\Db\Connection\ConnectionInterface::getTableSchema()

Obtains the schema information for the named table.

public abstract Yiisoft\Db\Schema\TableSchemaInterface|null getTableSchema ( string $name, boolean $refresh false )
$name string

The table name.

$refresh boolean

Whether to reload the table schema even if it's found in the cache.

return Yiisoft\Db\Schema\TableSchemaInterface|null

The schema information for the named table. Null if the named table doesn't exist.

                public function getTableSchema(string $name, bool $refresh = false): ?TableSchemaInterface;

            
getTransaction() public abstract method

Defined in: Yiisoft\Db\Connection\ConnectionInterface::getTransaction()

Returns the currently active transaction.

public abstract Yiisoft\Db\Transaction\TransactionInterface|null getTransaction ( )
return Yiisoft\Db\Transaction\TransactionInterface|null

The currently active transaction. Null if no active transaction.

                public function getTransaction(): ?TransactionInterface;

            
isActive() public abstract method

Defined in: Yiisoft\Db\Connection\ConnectionInterface::isActive()

Returns a value indicating whether the DB connection is active.

public abstract boolean isActive ( )
return boolean

Whether the DB connection is active.

                public function isActive(): bool;

            
isSavepointEnabled() public abstract method
public abstract boolean isSavepointEnabled ( )
return boolean

Whether this DBMS supports savepoint.

                public function isSavepointEnabled(): bool;

            
open() public abstract method

Defined in: Yiisoft\Db\Connection\ConnectionInterface::open()

Establishes a DB connection.

It does nothing if a DB connection is active.

public abstract void open ( )
throws Yiisoft\Db\Exception\Exception

If connection fails.

throws Yiisoft\Db\Exception\InvalidConfigException

If a connection can't be established because of incomplete configuration.

                public function open(): void;

            
quoteValue() public abstract method

Defined in: Yiisoft\Db\Connection\ConnectionInterface::quoteValue()

Quotes a value for use in a query.

public abstract mixed quoteValue ( mixed $value )
$value mixed
return mixed

The quoted string.

throws Yiisoft\Db\Exception\Exception
throws Yiisoft\Db\Exception\InvalidConfigException

                public function quoteValue(mixed $value): mixed;

            
select() public abstract method

Defined in: Yiisoft\Db\Connection\ConnectionInterface::select()

Creates a new {@see Query} instance with the specified columns to be selected.

public abstract Yiisoft\Db\Query\QueryInterface select ( array|Yiisoft\Db\Expression\ExpressionInterface|scalar $columns = [], string|null $option null )
$columns array|Yiisoft\Db\Expression\ExpressionInterface|scalar

The columns to be selected. Columns can be specified in either a string (for example id, name) or an array (such as ['id', 'name']). Columns can be prefixed with table names (such as user.id) and/or contain column aliases (for example user.id AS user_id). The method will automatically quote the column names unless a column has some parenthesis (which means the column has a DB expression). A DB expression may also be passed in form of an {@see \Yiisoft\Db\Expression\ExpressionInterface} object. Note that if you are selecting an expression like CONCAT(first_name, ' ', last_name), you should use an array to specify the columns. Otherwise, the expression may be incorrectly split into several parts. When the columns are specified as an array, you may also use array keys as the column aliases (if a column doesn't need alias, don't use a string key).

$option string|null

More option that should be appended to the 'SELECT' keyword. For example, in MySQL, the option 'SQL_CALC_FOUND_ROWS' can be used.

                public function select(
    array|bool|float|int|string|ExpressionInterface $columns = [],
    ?string $option = null,
): QueryInterface;

            
setEmulatePrepare() public abstract method

Whether to turn on prepare statements emulation on PHP side.

Defaults to false, meaning {@see \PDO} will use database prepared statements support if possible.

For some databases (such as MySQL), you may need to set it to true so that {@see \PDO} can replace buggy prepared statements support provided by database itself.

The default value is null, which means using default {@see \PDO} ATTR_EMULATE_PREPARES value.

public abstract void setEmulatePrepare ( boolean $value )
$value boolean

Whether to turn on prepared statement emulation.

                public function setEmulatePrepare(bool $value): void;

            
setEnableSavepoint() public abstract method

Defined in: Yiisoft\Db\Connection\ConnectionInterface::setEnableSavepoint()

Whether to enable savepoint.

Note that if the underlying DBMS doesn't support savepoint, setting this property to be true will have no effect.

public abstract void setEnableSavepoint ( boolean $value )
$value boolean

Whether to enable savepoint.

                public function setEnableSavepoint(bool $value): void;

            
setTablePrefix() public abstract method

Defined in: Yiisoft\Db\Connection\ConnectionInterface::setTablePrefix()

The common prefix or suffix for table names.

If a table name is {{%TableName}}, then the percentage character % will be replaced with this property value. For example, {{%post}} becomes {{tbl_post}}.

public abstract void setTablePrefix ( string $value )
$value string

The common prefix or suffix for table names.

                public function setTablePrefix(string $value): void;

            
transaction() public abstract method

Defined in: Yiisoft\Db\Connection\ConnectionInterface::transaction()

Executes callback provided in a transaction.

public abstract mixed transaction ( Closure $closure, string|null $isolationLevel null )
$closure Closure

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 \Yiisoft\Db\Transaction\TransactionInterface::begin()} for details.

return mixed

Result of callback function.

throws Throwable

If there is any exception during query. In this case, the transaction will be rolled back.

                public function transaction(Closure $closure, ?string $isolationLevel = null): mixed;