Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"ext-dom": "*",
"ext-libxml": "*",
"ext-pdo": "*",
"karmabunny/interfaces": "^1.0",
"karmabunny/kb": "^3.58"
},
"require-dev": {
Expand Down
57 changes: 54 additions & 3 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 27 additions & 10 deletions src/Drivers/PdbMysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace karmabunny\pdb\Drivers;

use InvalidArgumentException;
use karmabunny\kb\Time;
use karmabunny\pdb\Exceptions\ConnectionException;
use karmabunny\pdb\Models\PdbColumn;
Expand Down Expand Up @@ -70,7 +69,7 @@ public function isMariadb(): bool


/** @inheritdoc */
public function getPermissions()
public function getPermissions(): array
{
$q = "SHOW GRANTS FOR CURRENT_USER()";
$res = $this->query($q, [], 'col');
Expand Down Expand Up @@ -100,7 +99,7 @@ public function getPermissions()


/** @inheritdoc */
public function getTableNames(string $filter = '*', bool $strip = true)
public function getTableNames(string $filter = '*', bool $strip = true): array
{
$q = "SELECT TABLE_NAME
FROM INFORMATION_SCHEMA.TABLES
Expand Down Expand Up @@ -139,7 +138,7 @@ public function getTableNames(string $filter = '*', bool $strip = true)


/** @inheritdoc */
public function tableExists(string $table)
public function tableExists(string $table): bool
{
$q = "SELECT 1
FROM INFORMATION_SCHEMA.TABLES
Expand All @@ -158,7 +157,7 @@ public function tableExists(string $table)


/** @inheritdoc */
public function fieldList(string $table)
public function fieldList(string $table): array
{
$q = "SELECT
COLUMN_NAME,
Expand Down Expand Up @@ -228,7 +227,7 @@ public function fieldList(string $table)


/** @inheritdoc */
public function indexList(string $table)
public function indexList(string $table): array
{
$q = "SELECT
INDEX_NAME,
Expand Down Expand Up @@ -265,7 +264,7 @@ public function indexList(string $table)


/** @inheritdoc */
public function getForeignKeys(string $table)
public function getForeignKeys(string $table): array
{
$q = "SELECT
K.CONSTRAINT_NAME,
Expand Down Expand Up @@ -314,7 +313,7 @@ public function getForeignKeys(string $table)


/** @inheritdoc */
public function getDependentKeys(string $table)
public function getDependentKeys(string $table): array
{
$q = "SELECT
K.CONSTRAINT_NAME,
Expand Down Expand Up @@ -365,7 +364,7 @@ public function getDependentKeys(string $table)


/** @inheritdoc */
public function getTableAttributes(string $table)
public function getTableAttributes(string $table): array
{
$q = "SELECT
T.CREATE_TIME,
Expand Down Expand Up @@ -393,7 +392,7 @@ public function getTableAttributes(string $table)


/** @inheritdoc */
public function extractEnumArr(string $table, string $column)
public function extractEnumArr(string $table, string $column): array
{
Pdb::validateIdentifier($table);
Pdb::validateIdentifier($column);
Expand All @@ -405,4 +404,22 @@ public function extractEnumArr(string $table, string $column)
return array_combine($arr, $arr);
}


/** @inheritdoc */
public function createLock(string $name, float $timeout = 0): bool
{
$key = substr($this->config->database . sha1($name), 0, 63);
$ok = $this->query("SELECT GET_LOCK(?, ?)", [$key, $timeout], 'val?');
return (bool) $ok;
}


/** @inheritdoc */
public function deleteLock(string $name): bool
{
$key = substr($this->config->database . sha1($name), 0, 63);
$ok = $this->query("SELECT RELEASE_LOCK(?)", [$key], 'val?');
return (bool) $ok;
}

}
31 changes: 22 additions & 9 deletions src/Drivers/PdbNoDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,58 +8,71 @@
class PdbNoDriver extends Pdb
{

public function getPermissions()
public function getPermissions(): array
{
throw new Exception('Not implemented: ' . __METHOD__);
}


public function getForeignKeys(string $table)
public function getForeignKeys(string $table): array
{
throw new Exception('Not implemented: ' . __METHOD__);
}


public function getDependentKeys(string $table)
public function getDependentKeys(string $table): array
{
throw new Exception('Not implemented: ' . __METHOD__);
}


/** @inheritdoc */
public function getTableAttributes(string $table)
public function getTableAttributes(string $table): array
{
throw new Exception('Not implemented: ' . __METHOD__);
}


public function extractEnumArr(string $table, string $column)
public function extractEnumArr(string $table, string $column): array
{
throw new Exception('Not implemented: ' . __METHOD__);
}


public function getTableNames(string $filter = '*', bool $strip = true)
public function getTableNames(string $filter = '*', bool $strip = true): array
{
throw new Exception('Not implemented: ' . __METHOD__);
}


public function tableExists(string $table)
public function tableExists(string $table): bool
{
throw new Exception('Not implemented: ' . __METHOD__);
}


public function fieldList(string $table)
public function fieldList(string $table): array
{
throw new Exception('Not implemented: ' . __METHOD__);
}


public function indexList(string $table)
public function indexList(string $table): array
{
throw new Exception('Not implemented: ' . __METHOD__);
}


/** @inheritdoc */
public function createLock(string $name, float $timeout = 0): bool
{
throw new Exception('Not implemented: ' . __METHOD__);
}


/** @inheritdoc */
public function deleteLock(string $name): bool
{
throw new Exception('Not implemented: ' . __METHOD__);
}
}
Loading