FaaPz/PDO

MD5 of column value in where clause

mridah opened this issue · 1 comments

suppose I have a table like this:

------ mytable-----
id  |   col1  |   col2   |   col3

I want to write the following statement in PDO:

select * from mytable where md5('some-salt' + id) = 'value-to-compare-to';

Is this possible ? @FaaPz @kwhat @bmutinda

kwhat commented
$value = 'value-to-compare-to';
$database->select()
                 ->from('mytable')
                 ->where(new Conditional('md5("some-salt" + id)', '=', $value))
                 ->execute();

OR

$database->select()
                 ->from('mytable')
                 ->where(new Conditional('md5("some-salt" + id)', '=', new Raw('value-to-compare-to')))
                 ->execute();