Created
February 6, 2015 21:07
-
-
Save benjaminmullard/9667cc564d6036fdf707 to your computer and use it in GitHub Desktop.
CodeIgniter helper functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php if (!defined('BASEPATH')) { exit; } | |
if (!function_exists('generate_uuid')) { | |
/** | |
* Generate a universally unique ID that can be used for sharding. | |
* | |
* @param integer $shard_id The ID to shard by. | |
* @param integer $seq Incrementing sequence for the database table. | |
* @return string Universally unique ID. | |
*/ | |
function generate_uuid($shard_id=0, $seq=0) { | |
return floor((microtime(TRUE) * 1000) - APP_EPOCH_MS) << 23 | | |
($shard_id % APP_NUM_SHARDS) << 10 | | |
($seq % 1024); | |
} | |
} | |
/* End of file custom_helper.php */ | |
/* Location: ./application/helpers/custom_helper.php */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment