1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-01 22:40:39 +02:00

[ticket/16643] Refactor installer tasks to use Doctrine DBAL

PHPBB3-16643
This commit is contained in:
Máté Bartus
2021-01-16 11:57:35 +01:00
parent aab2679966
commit 2a57477718
19 changed files with 1102 additions and 676 deletions

View File

@@ -17,6 +17,7 @@ use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver\Exception as DriverException;
use Doctrine\DBAL\Driver\Statement as DriverStmt;
use Doctrine\DBAL\Exception;
use Doctrine\DBAL\Result;
use Doctrine\DBAL\Statement;
use phpbb\db\doctrine\connection_factory;
use phpbb\install\helper\config;
@@ -70,6 +71,27 @@ abstract class database_task extends task_base
}
}
/**
* Run a query and return the result object.
*
* @param string $sql SQL query.
*
* @return Result|null Result of the query.
*/
protected function query(string $sql) : ?Result
{
try
{
return $this->conn->executeQuery($sql);
}
catch (Exception $e)
{
$this->report_error($e->getMessage());
}
return null;
}
/**
* Creates a prepared statement.
*
@@ -132,6 +154,25 @@ abstract class database_task extends task_base
}
}
/**
* Returns the last insert ID.
*
* @return string|null The last insert ID.
*/
protected function get_last_insert_id() : ?string
{
try
{
return $this->conn->lastInsertId();
}
catch (Exception $e)
{
$this->report_error($e->getMessage());
}
return null;
}
/**
* Report a database error.
*