0 follower

Final Class Yiisoft\Db\Sqlite\Command

InheritanceYiisoft\Db\Sqlite\Command » Yiisoft\Db\Driver\Pdo\AbstractPdoCommand

Implements a database command that can be executed with a PDO (PHP Data Object) database connection for SQLite Server.

Public Methods

Hide inherited methods

Method Description Defined By
execute() Executes the SQL statement. Yiisoft\Db\Sqlite\Command
showDatabases() Yiisoft\Db\Sqlite\Command

Protected Methods

Hide inherited methods

Method Description Defined By
queryInternal() Performs the actual DB query of an SQL statement. Yiisoft\Db\Sqlite\Command

Method Details

Hide inherited methods

execute() public method

Executes the SQL statement.

This method should only be used for executing a non-query SQL statement, such as INSERT, DELETE, UPDATE SQLs. No result set will be returned.

public integer execute ( )
return integer

Number of rows affected by the execution.

throws \Yiisoft\Db\Exception\Exception
throws Throwable

The execution failed.

                public function execute(): int
{
    $sql = $this->getSql();
    $params = $this->params;
    $statements = $this->splitStatements($sql, $params);
    if ($statements === false) {
        return parent::execute();
    }
    $result = 0;
    foreach ($statements as $statement) {
        [$statementSql, $statementParams] = $statement;
        $this->setSql($statementSql)->bindValues($statementParams);
        $result = parent::execute();
    }
    $this->setSql($sql)->bindValues($params);
    return $result;
}

            
queryInternal() protected method

Performs the actual DB query of an SQL statement.

protected mixed queryInternal ( integer $queryMode )
$queryMode integer

Return results as DataReader

return mixed

The method execution result.

throws \Yiisoft\Db\Exception\Exception
throws Throwable

If the query causes any problem.

                protected function queryInternal(int $queryMode): mixed
{
    $sql = $this->getSql();
    $params = $this->params;
    $statements = $this->splitStatements($sql, $params);
    if ($statements === false || $statements === []) {
        return parent::queryInternal($queryMode);
    }
    [$lastStatementSql, $lastStatementParams] = array_pop($statements);
    foreach ($statements as $statement) {
        [$statementSql, $statementParams] = $statement;
        $this->setSql($statementSql)->bindValues($statementParams);
        parent::execute();
    }
    $this->setSql($lastStatementSql)->bindValues($lastStatementParams);
    $result = parent::queryInternal($queryMode);
    $this->setSql($sql)->bindValues($params);
    return $result;
}

            
showDatabases() public method

public array showDatabases ( )

                public function showDatabases(): array
{
    $sql = <<<SQL
    SELECT name FROM pragma_database_list;
    SQL;
    return $this->setSql($sql)->queryColumn();
}