We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

md5 condition with table column

Hello Team

I am getting stuck with making condtion with md5 value. I have id in md5 fomat and want to match with id column in table. I would like to have query like : find("md5(id) = $id").

But i am not getting success, please help me asap.

Thanks!



85.5k

i am not 100% sure but u probably need to wrap it in raw Value

https://docs.phalcon.io/en/latest/api/Phalcon_Db_RawValue.html

Why not using php's md5 function?

$foo = md5($id);
$result = Robots::find("id = '" . $foo . "'");

or using parameters:

$foo = md5($id);

$conditions = "id = :id:";

$parameters = array(
    "id" => $foo
);

$results = Robots::find(
    array(
        $conditions,
        "bind" => $parameters
    )
);