for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Yiisoft\Db\Mssql;
use PDOException;
use Yiisoft\Db\Driver\PDO\CommandPDO as AbstractCommandPDO;
use Yiisoft\Db\Driver\PDO\ConnectionPDOInterface;
use Yiisoft\Db\Exception\ConvertException;
use Yiisoft\Db\QueryBuilder\QueryBuilderInterface;
use function is_array;
final class CommandPDO extends AbstractCommandPDO
{
/**
* @inheritDoc
*/
public function insertEx(string $table, array $columns): bool|array
$params = [];
$sql = $this->queryBuilder()->insertEx($table, $columns, $params);
$this->setSql($sql)->bindValues($params);
$this->prepare(false);
/** @psalm-var array|bool */
$result = $this->queryOne();
return is_array($result) ? $result : false;
}
public function queryBuilder(): QueryBuilderInterface
return $this->db->getQueryBuilder();
* @psalm-suppress UnusedClosureParam
protected function internalExecute(string|null $rawSql): void
$attempt = 0;
while (true) {
try {
if (
++$attempt === 1
&& $this->isolationLevel !== null
&& $this->db->getTransaction() === null
) {
$this->db->transaction(
fn (ConnectionPDOInterface $db) => $this->internalExecute($rawSql),
$db
If this is a false-positive, you can also ignore this issue in your code via the ignore-unused annotation
ignore-unused
fn (/** @scrutinizer ignore-unused */ ConnectionPDOInterface $db) => $this->internalExecute($rawSql),
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
$this->isolationLevel
);
} else {
$this->pdoStatement?->execute();
break;
} catch (PDOException $e) {
$rawSql = $rawSql ?: $this->getRawSql();
$e = (new ConvertException($e, $rawSql))->run();
if ($this->retryHandler === null || !($this->retryHandler)($e, $attempt)) {
throw $e;
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.