Final Class Yiisoft\Db\Mysql\Connection
| Inheritance | Yiisoft\Db\Mysql\Connection » Yiisoft\Db\Driver\Pdo\AbstractPdoConnection |
|---|
Implements a connection to a database via PDO (PHP Data Objects) for MySQL, MariaDB.
Public Methods
Method Details
| public void close ( ) |
public function close(): void
{
if ($this->pdo !== null) {
$this->logger?->log(
LogLevel::DEBUG,
'Closing DB connection: ' . $this->driver->getDsn() . ' ' . __METHOD__,
);
// Solution for close connections {@link https://stackoverflow.com/questions/18277233/pdo-closing-connection}
try {
$this->pdo->exec('KILL CONNECTION_ID()');
} catch (Throwable) {
}
$this->pdo = null;
$this->transaction = null;
}
}
| public \Yiisoft\Db\Driver\Pdo\PdoCommandInterface createCommand ( string|null $sql = null, array $params = [] ) | ||
| $sql | string|null | |
| $params | array | |
public function createCommand(?string $sql = null, array $params = []): PdoCommandInterface
{
$command = new Command($this);
if ($sql !== null) {
$command->setSql($sql);
}
if ($this->logger !== null) {
$command->setLogger($this->logger);
}
if ($this->profiler !== null) {
$command->setProfiler($this->profiler);
}
return $command->bindValues($params);
}
| public \Yiisoft\Db\Transaction\TransactionInterface createTransaction ( ) |
public function createTransaction(): TransactionInterface
{
return new Transaction($this);
}
| public string getColumnBuilderClass ( ) |
public function getColumnBuilderClass(): string
{
return ColumnBuilder::class;
}
| public \Yiisoft\Db\Schema\Column\ColumnFactoryInterface getColumnFactory ( ) |
public function getColumnFactory(): ColumnFactoryInterface
{
return $this->columnFactory ??= new ColumnFactory();
}
| public \Yiisoft\Db\QueryBuilder\QueryBuilderInterface getQueryBuilder ( ) |
public function getQueryBuilder(): QueryBuilderInterface
{
return $this->queryBuilder ??= new QueryBuilder($this);
}
| public \Yiisoft\Db\Schema\QuoterInterface getQuoter ( ) |
public function getQuoter(): QuoterInterface
{
return $this->quoter ??= new Quoter('`', '`', $this->getTablePrefix());
}
| public \Yiisoft\Db\Schema\SchemaInterface getSchema ( ) |
public function getSchema(): SchemaInterface
{
return $this->schema ??= new Schema($this, $this->schemaCache);
}
| public \Yiisoft\Db\Connection\ServerInfoInterface getServerInfo ( ) |
public function getServerInfo(): ServerInfoInterface
{
return $this->serverInfo ??= new ServerInfo($this);
}
Signup or Login in order to comment.