add column unique numbering scheme, more efficient selects

This commit is contained in:
2018-08-04 19:57:59 +02:00
parent 69bda25bbb
commit fabc3ad24e
23 changed files with 452 additions and 173 deletions
+22
View File
@@ -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;
}
}