php - Mysqli Prepared Statement with AES Encryption -
this question has answer here:
- why mysqli num_rows return 0? 2 answers
i'm having trouble getting prepared statement select rows database thats using built in aes_encryption. if run query though phpmyadmin, works fine, , returns expected values, running through bind_params returns -1.
returns -1 , no rows
$query = "select `col0`, cast(aes_decrypt(`col1`, '$this->key') char(50)) col1_decrypt, cast(aes_decrypt(`col2`, '$this->key') char(50)) col2_decrypt `$table` `$field` = aes_encrypt(?, '$this->key')"; // tried in clause. // -- cast(aes_decrypt(`$field`, '$this->key') char(50)) = ?"; if($stmt = $this->db->prepare($query)) { try { $stmt->bind_param('s', $incomingfield); } catch (exception $e) { // testing print $this->db->error; } $stmt->execute(); if($stmt->num_rows > 0) { print "found"; } else { print "not found"; }
return
(mysqli_stmt)#52 (10) { ["affected_rows"]=> int(-1) ["insert_id"]=> int(0) ["num_rows"]=> int(0)
running normal query:
select `col0`, cast(aes_decrypt(`col1`, 'secret key') char(50)) col1_decrypt, cast(aes_decrypt(`col2`, 'secret key') char(50)) col2_decrypt `tablename` `field` = aes_encrypt('search value', 'secret key')
will return row i'm looking for.
stupid question... forgot
$stmt->store_result();
Comments
Post a Comment