mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-24 21:03:19 +09:00
Generate sequential mid instead of random characters
This commit is contained in:
parent
5fc98dc4e3
commit
c64a87041a
3 changed files with 45 additions and 31 deletions
|
|
@ -529,6 +529,37 @@ class ModuleModel extends Module
|
|||
return $target_module_info[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the next available mid with the given prefix.
|
||||
*
|
||||
* @param string $prefix
|
||||
* @return string
|
||||
*/
|
||||
public static function getNextAvailableMid($prefix)
|
||||
{
|
||||
$prefix = trim($prefix);
|
||||
if (!$prefix)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
$args = new stdClass;
|
||||
$args->mid_prefix = $prefix;
|
||||
$output = executeQueryArray('module.getMidInfo', $args, ['mid']);
|
||||
|
||||
$max = 0;
|
||||
$len = strlen($prefix);
|
||||
foreach ($output->data as $info)
|
||||
{
|
||||
$suffix = substr($info->mid, $len);
|
||||
if (ctype_digit($suffix))
|
||||
{
|
||||
$max = max($max, intval($suffix));
|
||||
}
|
||||
}
|
||||
return $prefix . ($max + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get a complete list of mid, which is created in the DB
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue