Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This sounds like an urban legend to me.</p> <p><code>bin2hex()</code> maps each byte in the input to <em>two</em> bytes in the output (<code>'a'</code> -> <code>'61'</code>), so you should notice a significant memory increase of the script performing the query - it should use at least as much memory more as the byte length of the binary data to be inserted.</p> <p>Furthermore, this implies that running <code>bin2hex()</code> on a long string takes <em>much</em> longer than running <code>mysql_real_escape string()</code>, which - as explained in <a href="http://dev.mysql.com/doc/refman/5.0/en/mysql-real-escape-string.html" rel="noreferrer">MySQL's documentation</a> - just escapes 6 characters: <code>NULL</code>, <code>\r</code>, <code>\n</code>, <code>\</code>, <code>,</code> and 'Control-Z'.</p> <p>That was for the PHP part, now for MySQL: The server needs to do the reverse operation to store the data correctly. Reversing either of the functions takes almost as long as the original operation - the reverse function of <code>mysql_real_escape_string()</code> needs to replace escaped values (<code>\\</code>) with unescaped ones (<code>\</code>), whereas the reverse of <code>bin2hex()</code> would need to replace <em>each and every byte tuple</em> with a new byte.</p> <p>Since calling <code>mysql_real_escape_string()</code> on binary data is safe (according to MySQL's and <a href="http://php.net/manual/en/function.mysql-real-escape-string.php" rel="noreferrer">PHP's documentation</a> or even when just considering that the operation does not do any other conversions than the ones listed above), it would make absolutely no sense to perform such a costly operation.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload