mirror of
https://code.castopod.org/adaures/castopod
synced 2025-06-05 17:02:01 +00:00

- add james-heinrich/getid3 library as a dependency to composer.json - update DEPENDENCIES.md file - fix episodes table migration script - add js devDependencies: prettier, @prettier/plugin-php and lint-staged to automatically format staged files before commit - reformat all files to the prettier format - refactor code by separating some logic as helper functions - overwrite existing files when uploading new files with the same name fixes #1
34 lines
716 B
PHP
34 lines
716 B
PHP
<?php
|
|
/**
|
|
* @copyright 2020 Podlibre
|
|
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
|
* @link https://castopod.org/
|
|
*/
|
|
|
|
/**
|
|
* Get all possible enum values for a table field
|
|
*
|
|
* @param string $table
|
|
* @param string $field
|
|
*
|
|
* @return array $enums
|
|
*/
|
|
function field_enums($table = '', $field = '')
|
|
{
|
|
$enums = [];
|
|
if ($table == '' || $field == '') {
|
|
return $enums;
|
|
}
|
|
$db = \Config\Database::connect();
|
|
preg_match_all(
|
|
"/'(.*?)'/",
|
|
$db->query("SHOW COLUMNS FROM {$table} LIKE '{$field}'")->getRow()
|
|
->Type,
|
|
$matches
|
|
);
|
|
foreach ($matches[1] as $value) {
|
|
$enums[$value] = $value;
|
|
}
|
|
return $enums;
|
|
}
|