This is not easy to do with Class::DBI. You are probably better off not using the MySQL PASSWORD() command and using perl's crypt() to achieve the same results (or even better, us MD5 or SHA1). And a quote from the MySQL docs suggests you shouldn't be using this function anyway:

Note: The PASSWORD() function is used by the authentication system in MySQL Server, you should NOT use it in your own applications

If you want to handle this on the perl side with MD5 or SHA1 hashes you can use the trigger support in Class::DBI to handle the UPDATE statement above (a before INSERT or UPDATE trigger can hash the password field before it is sent to the database).

As for the SELECT statement, I would probably just create a custom method in your Class::DBI module that checked the password for you. It could hash the password and do the SQL call and return true or false. Your call to check a password could then simply be My::User->check_password($username, $password). There are examples in the Class::DBI docs that explain how to create your own custom SQL statements and wrap them up in a method.

- Cees


In reply to Re: How to call MySQL's PASSWORD() from Class::DBI? by cees
in thread How to call MySQL's PASSWORD() from Class::DBI? by monsieur_champs

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.