add column unique numbering scheme, more efficient selects
This commit is contained in:
@@ -991,4 +991,26 @@ class Utils
|
||||
|
||||
throw new FormatException("Bad time interval: \"$time\"");
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert number to arbitrary alphabet, using a system similar to EXCEL column numbering.
|
||||
*
|
||||
* @param int $n
|
||||
* @param string[] $alphabet - array of characters to use
|
||||
* @return string
|
||||
*/
|
||||
public static function alphabetEncode($n, $alphabet)
|
||||
{
|
||||
$key = '';
|
||||
$abcsize = count($alphabet);
|
||||
$i = $n;
|
||||
|
||||
do {
|
||||
$mod = $i % $abcsize;
|
||||
$key = $alphabet[$mod] . $key;
|
||||
$i = (($i - $mod) / $abcsize) - 1;
|
||||
} while($i >= 0);
|
||||
|
||||
return $key;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user