[ticket/13162] Add truncate table functionality to doctrine tools

PHPBB3-13162
This commit is contained in:
Marc Alexander 2023-11-09 22:05:42 +01:00
parent afe41e3916
commit 5a1fe1db12
No known key found for this signature in database
GPG key ID: 50E0D2423696F995

View file

@ -15,6 +15,7 @@ namespace phpbb\db\tools;
use Doctrine\DBAL\Connection; use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Exception; use Doctrine\DBAL\Exception;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Schema\AbstractAsset; use Doctrine\DBAL\Schema\AbstractAsset;
use Doctrine\DBAL\Schema\AbstractSchemaManager; use Doctrine\DBAL\Schema\AbstractSchemaManager;
use Doctrine\DBAL\Schema\Index; use Doctrine\DBAL\Schema\Index;
@ -363,6 +364,24 @@ class doctrine implements tools_interface
); );
} }
/**
* Truncate the table
*
* @param string $table_name
* @return void
*/
public function sql_truncate_table(string $table_name)
{
try
{
$this->connection->executeQuery($this->get_schema_manager()->getDatabasePlatform()->getTruncateTableSQL($table_name));
}
catch (Exception $e)
{
return;
}
}
/** /**
* Returns an array of indices for either unique and primary keys, or simple indices. * Returns an array of indices for either unique and primary keys, or simple indices.
* *