* @package generis */ class common_uri_MicrotimeUriProvider implements common_uri_UriProvider { // --- ASSOCIATIONS --- // --- ATTRIBUTES --- // --- OPERATIONS --- /** * Generates a URI based on the value of PHP microtime(). * * @access public * @author Jerome Bogaerts, * @return string */ public function provide() { $returnValue = (string) ''; $modelUri = common_ext_NamespaceManager::singleton()->getLocalNamespace()->getUri(); $dbWrapper = core_kernel_classes_DbWrapper::singleton(); $uriExist = false; do { list($usec, $sec) = explode(" ", microtime()); $uri = $modelUri . 'i' . (str_replace(".", "", $sec . "" . $usec)); $sqlResult = $dbWrapper->query("SELECT COUNT(subject) AS num FROM statements WHERE subject = '" . $uri . "'"); if ($row = $sqlResult->fetch()) { $found = (int)$row['num']; if ($found > 0) { $uriExist = true; } $sqlResult->closeCursor(); } } while ($uriExist); $returnValue = $uri; return (string) $returnValue; } }