Interface Yiisoft\Db\Driver\Pdo\PdoConnectionInterface
| Extends | Yiisoft\Db\Connection\ConnectionInterface |
|---|---|
| Implemented by | Yiisoft\Db\Driver\Pdo\AbstractPdoConnection |
This interface defines a set of methods to implement in a class that allows to connect to a database with PDO (PHP Data Objects).
Public Methods
Method Details
Defined in: Yiisoft\Db\Connection\ConnectionInterface::beginTransaction()
Starts a transaction and returns it, creating a new transaction object only if none is currently active.
| public abstract beginTransaction( string|null $isolationLevel = null ): Yiisoft\Db\Transaction\TransactionInterface | ||
| $isolationLevel | string|null |
The isolation level to use for this transaction. Yiisoft\Db\Transaction\TransactionInterface::begin() for details. |
| return | Yiisoft\Db\Transaction\TransactionInterface |
The transaction. |
|---|---|---|
| throws | Yiisoft\Db\Exception\Exception | |
| throws | Yiisoft\Db\Exception\InvalidConfigException | |
| throws | Yiisoft\Db\Exception\NotSupportedException | |
| throws | Throwable | |
public function beginTransaction(?string $isolationLevel = null): TransactionInterface;
Defined in: Yiisoft\Db\Connection\ConnectionInterface::close()
Closes the currently active DB connection.
It does nothing if the connection is already closed.
| public abstract close( ): void |
public function close(): void;
Defined in: Yiisoft\Db\Connection\ConnectionInterface::createBatchQueryResult()
Creates Yiisoft\Db\Query\BatchQueryResultInterface instance.
| public abstract createBatchQueryResult( Yiisoft\Db\Query\QueryInterface $query ): Yiisoft\Db\Query\BatchQueryResultInterface | ||
| $query | Yiisoft\Db\Query\QueryInterface |
The query to execute. |
| return | Yiisoft\Db\Query\BatchQueryResultInterface |
The batch query result. |
|---|---|---|
public function createBatchQueryResult(QueryInterface $query): BatchQueryResultInterface;
Defined in: Yiisoft\Db\Connection\ConnectionInterface::createCommand()
Creates a command for execution.
| public abstract createCommand( string|null $sql = null, array $params = [] ): Yiisoft\Db\Command\CommandInterface | ||
| $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. |
|---|---|---|
| throws | Yiisoft\Db\Exception\Exception | |
| throws | Yiisoft\Db\Exception\InvalidConfigException | |
public function createCommand(?string $sql = null, array $params = []): CommandInterface;
Defined in: Yiisoft\Db\Connection\ConnectionInterface::createQuery()
Creates Yiisoft\Db\Query\QueryInterface instance.
| public abstract createQuery( ): Yiisoft\Db\Query\QueryInterface | ||
| return | Yiisoft\Db\Query\QueryInterface |
The query. |
|---|---|---|
public function createQuery(): QueryInterface;
Defined in: Yiisoft\Db\Connection\ConnectionInterface::createTransaction()
Creates Yiisoft\Db\Transaction\TransactionInterface instance.
| public abstract createTransaction( ): Yiisoft\Db\Transaction\TransactionInterface | ||
| return | Yiisoft\Db\Transaction\TransactionInterface |
The transaction. |
|---|---|---|
public function createTransaction(): TransactionInterface;
Returns the PDO instance for the current connection.
This method will open the DB connection and then return PDO.
| public abstract getActivePdo( ): PDO | ||
| return | PDO |
The PDO instance for the current connection. |
|---|---|---|
| throws | Yiisoft\Db\Exception\Exception | |
| throws | Yiisoft\Db\Exception\InvalidConfigException | |
public function getActivePdo(): PDO;
Defined in: Yiisoft\Db\Connection\ConnectionInterface::getColumnBuilderClass()
Returns the column builder class name for the current DB connection.
| public abstract getColumnBuilderClass( ): string |
public function getColumnBuilderClass(): string;
Defined in: Yiisoft\Db\Connection\ConnectionInterface::getColumnFactory()
Returns the column factory for creating column instances.
| public abstract getColumnFactory( ): Yiisoft\Db\Schema\Column\ColumnFactoryInterface |
public function getColumnFactory(): ColumnFactoryInterface;
Returns current DB driver.
| public abstract getDriver( ): Yiisoft\Db\Driver\Pdo\PdoDriverInterface | ||
| return | Yiisoft\Db\Driver\Pdo\PdoDriverInterface |
The driver used to create current connection. |
|---|---|---|
public function getDriver(): PdoDriverInterface;
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 getDriverName( ): string | ||
| return | string |
The name of the DB driver for the current |
|---|---|---|
public function getDriverName(): string;
Whether to emulate prepared statements on PHP side.
See also setEmulatePrepare().
| public abstract getEmulatePrepare( ): boolean|null |
public function getEmulatePrepare(): ?bool;
Defined in: Yiisoft\Db\Connection\ConnectionInterface::getLastInsertId()
Returns the ID of the last inserted row or a sequence value.
| public abstract getLastInsertId( string|null $sequenceName = null ): string | ||
| $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;
The PHP PDO instance associated with this DB connection.
This property is mainly managed by open() and 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 getPdo( ): PDO|null | ||
| return | PDO|null |
The PHP PDO instance associated with this DB connection. |
|---|---|---|
public function getPdo(): ?PDO;
Defined in: Yiisoft\Db\Connection\ConnectionInterface::getQueryBuilder()
Returns the query builder for the current DB connection.
| public abstract getQueryBuilder( ): Yiisoft\Db\QueryBuilder\QueryBuilderInterface | ||
| return | Yiisoft\Db\QueryBuilder\QueryBuilderInterface |
The query builder for the current DB connection. |
|---|---|---|
public function getQueryBuilder(): QueryBuilderInterface;
Defined in: Yiisoft\Db\Connection\ConnectionInterface::getQuoter()
Returns quoter helper for current DB connection.
| public abstract getQuoter( ): Yiisoft\Db\Schema\QuoterInterface | ||
| return | Yiisoft\Db\Schema\QuoterInterface |
The quoter helper for the current DB connection. |
|---|---|---|
public function getQuoter(): QuoterInterface;
Defined in: Yiisoft\Db\Connection\ConnectionInterface::getSchema()
Returns the schema information for the database opened by this connection.
| public abstract getSchema( ): Yiisoft\Db\Schema\SchemaInterface | ||
| return | Yiisoft\Db\Schema\SchemaInterface |
The schema information for the database opened by this connection. |
|---|---|---|
public function getSchema(): SchemaInterface;
Defined in: Yiisoft\Db\Connection\ConnectionInterface::getServerInfo()
Returns Yiisoft\Db\Connection\ServerInfoInterface instance that provides information about the database server.
| public abstract getServerInfo( ): Yiisoft\Db\Connection\ServerInfoInterface |
public function getServerInfo(): ServerInfoInterface;
Defined in: Yiisoft\Db\Connection\ConnectionInterface::getTablePrefix()
Returns table prefix for current DB connection.
| public abstract getTablePrefix( ): string | ||
| return | string |
The table prefix for the current DB connection. |
|---|---|---|
public function getTablePrefix(): string;
Defined in: Yiisoft\Db\Connection\ConnectionInterface::getTableSchema()
Obtains the schema information for the named table.
| public abstract getTableSchema( string $name, boolean $refresh = false ): Yiisoft\Db\Schema\TableSchemaInterface|null | ||
| $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;
Defined in: Yiisoft\Db\Connection\ConnectionInterface::getTransaction()
Returns the currently active transaction.
| public abstract getTransaction( ): Yiisoft\Db\Transaction\TransactionInterface|null | ||
| return | Yiisoft\Db\Transaction\TransactionInterface|null |
The currently active transaction. Null if there is no active transaction. |
|---|---|---|
public function getTransaction(): ?TransactionInterface;
Defined in: Yiisoft\Db\Connection\ConnectionInterface::isActive()
Whether the DB connection is active.
| public abstract isActive( ): boolean | ||
| return | boolean |
Whether the DB connection is active. |
|---|---|---|
public function isActive(): bool;
Defined in: Yiisoft\Db\Connection\ConnectionInterface::isSavepointEnabled()
Whether this DBMS supports savepoint.
| public abstract isSavepointEnabled( ): boolean | ||
| return | boolean |
Whether this DBMS supports savepoint. |
|---|---|---|
public function isSavepointEnabled(): bool;
Defined in: Yiisoft\Db\Connection\ConnectionInterface::open()
Establishes a DB connection.
It does nothing if a DB connection is active.
| public abstract open( ): void | ||
| 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;
Defined in: Yiisoft\Db\Connection\ConnectionInterface::quoteValue()
Quotes a value for use in a query.
| public abstract quoteValue( mixed $value ): mixed | ||
| $value | mixed | |
| return | mixed |
The quoted string. |
|---|---|---|
| throws | Yiisoft\Db\Exception\Exception | |
| throws | Yiisoft\Db\Exception\InvalidConfigException | |
public function quoteValue(mixed $value): mixed;
Defined in: Yiisoft\Db\Connection\ConnectionInterface::select()
Creates a new Query instance with the specified columns to be selected.
| public abstract select( array|Yiisoft\Db\Expression\ExpressionInterface|scalar $columns = [], string|null $option = null ): Yiisoft\Db\Query\QueryInterface | ||
| $columns | array|Yiisoft\Db\Expression\ExpressionInterface|scalar |
The columns to be selected.
Columns can be specified in either a string (for example |
| $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;
Whether to turn on prepare statements emulation on PHP side.
Defaults to false, meaning 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 PDO can
replace buggy prepared statements support provided by database itself.
The default value is null, which means using default PDO ATTR_EMULATE_PREPARES value.
| public abstract setEmulatePrepare( boolean $value ): void | ||
| $value | boolean |
Whether to turn on prepared statement emulation. |
public function setEmulatePrepare(bool $value): void;
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 setEnableSavepoint( boolean $value ): void | ||
| $value | boolean |
Whether to enable savepoint. |
public function setEnableSavepoint(bool $value): void;
Defined in: Yiisoft\Db\Connection\ConnectionInterface::setTablePrefix()
Sets 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 setTablePrefix( string $value ): void | ||
| $value | string |
The common prefix or suffix for table names. |
public function setTablePrefix(string $value): void;
Defined in: Yiisoft\Db\Connection\ConnectionInterface::transaction()
Executes callback provided in a transaction.
| public abstract transaction( Closure $closure, string|null $isolationLevel = null ): mixed | ||
| $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. 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;
Signup or Login in order to comment.