mirror of
https://github.com/friendica/friendica
synced 2024-11-18 23:03:40 +00:00
We already have got a function to check if a table exists
This commit is contained in:
parent
8b2c51baf2
commit
ec3290da3b
3 changed files with 3 additions and 26 deletions
|
@ -741,17 +741,6 @@ class DBA
|
|||
return DI::dba()->processlist();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if the given table exists
|
||||
*
|
||||
* @param string $table
|
||||
* @return bool
|
||||
*/
|
||||
public static function tableExists(string $table)
|
||||
{
|
||||
return DI::dba()->tableExists($table);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a database variable
|
||||
*
|
||||
|
|
|
@ -988,7 +988,7 @@ class DBStructure
|
|||
*/
|
||||
public static function checkInitialValues()
|
||||
{
|
||||
if (DBA::tableExists('contact') && !DBA::exists('contact', ['id' => 0])) {
|
||||
if (self::existsTable('contact') && !DBA::exists('contact', ['id' => 0])) {
|
||||
DBA::insert('contact', ['nurl' => '']);
|
||||
$lastid = DBA::lastInsertId();
|
||||
if ($lastid != 0) {
|
||||
|
@ -996,7 +996,7 @@ class DBStructure
|
|||
}
|
||||
}
|
||||
|
||||
if (DBA::tableExists('permissionset') && !DBA::exists('permissionset', ['id' => 0])) {
|
||||
if (self::existsTable('permissionset') && !DBA::exists('permissionset', ['id' => 0])) {
|
||||
DBA::insert('permissionset', ['allow_cid' => '', 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '']);
|
||||
$lastid = DBA::lastInsertId();
|
||||
if ($lastid != 0) {
|
||||
|
@ -1004,7 +1004,7 @@ class DBStructure
|
|||
}
|
||||
}
|
||||
|
||||
if (DBA::tableExists('tag') && !DBA::exists('tag', ['id' => 0])) {
|
||||
if (self::existsTable('tag') && !DBA::exists('tag', ['id' => 0])) {
|
||||
DBA::insert('tag', ['name' => '']);
|
||||
$lastid = DBA::lastInsertId();
|
||||
if ($lastid != 0) {
|
||||
|
|
|
@ -1660,18 +1660,6 @@ class Database
|
|||
return (["list" => $statelist, "amount" => $processes]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if the given table exists
|
||||
*
|
||||
* @param string $table
|
||||
* @return bool
|
||||
*/
|
||||
public function tableExists(string $table)
|
||||
{
|
||||
return $this->exists(['information_schema' => 'tables'],
|
||||
['table_name' => $table, 'table_schema' => $this->databaseName()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a database variable
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue