Tag Archives: MySQL
Python MySQL Associative Array
By default, the MySQLdb module to access a MySQL database returns the data as an integer indexed array. Sometimes this is not desirable and an associative array is preferred, such as the mysql_fetch_assoc function in PHP. In addition, we will … Continue reading
PHP function to validate MySQL UUID or GUID
/** * Function to validate a generated GUID / UUID * @param string $guid GUID * @return bool */ function validGUID($guid){ return preg_match(‘#^[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}$#’, $guid); } Bookmark on Delicious Digg this post Recommend on Facebook share via Reddit Share with Stumblers … Continue reading
PHP function to emulate MySQL UUID
/** * uuid * * uuid() simply replicates MySQL’s UUID function, which returns a 36 * character "random" hash (32 alphanumeric, 4 dashes). * @return string */ function uuid(){ return sprintf(‘%04x%04x-%04x-%04x-%04x-%04x%04x%04x’, mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0x0fff) | … Continue reading
