Welcome Guest, Not a member yet? Register   Sign In
Insert binary value into table fails.
#3

(This post was last modified: 11-19-2018, 02:45 PM by jreklund.)

That's a HEX right? You need to use hex2bin before inserting it into your DB. And bin2hex to return it from the database.
I'm using BINARY(16) for storing UUID to get a faster JOINS. But why do you need to store password in BINARY?

PHP Code:
if ( ! function_exists('UUID_TO_BIN'))
{
    function 
UUID_TO_BIN($uuid) {
        
$uuid hex2bin(str_replace('-','',$uuid));
        return 
$uuid;
    }
}

if ( ! 
function_exists('BIN_TO_UUID'))
{
    function 
BIN_TO_UUID($uuid) {
        if( empty(
$uuid) ) return;
        
$uuid bin2hex($uuid);
        
$uuid substr($uuid08) . '-' substr($uuid84) . '-' substr($uuid124) . '-' substr($uuid164)  . '-' substr($uuid20);
        return 
$uuid;
    }

Reply


Messages In This Thread
RE: Insert binary value into table fails. - by jreklund - 11-19-2018, 02:44 PM



Theme © iAndrew 2016 - Forum software by © MyBB