in reply to Re: Class::DBI and MySQL ENCODE/DECODE
in thread Class::DBI and MySQL ENCODE/DECODE

Well yes, but ...

SELECT %s
FROM __TABLE__
WHERE __IDENTIFIER__

or

UPDATE __TABLE__
SET %s
WHERE __IDENTIFIER__

One would need to define custom SQL for the fields that need to be encoded or decoded, or else encode or decode everything.

So it seems that the string being passed in must contain the ENCODE/DECODE only for the fields that need it, or else modify the query after it has been built.

What I am trying to identify is where to put it to avoid duplication of code and/or special casing.

  • Comment on Re^2: Class::DBI and MySQL ENCODE/DECODE

Replies are listed 'Best First'.
Re^3: Class::DBI and MySQL ENCODE/DECODE
by perrin (Chancellor) on Dec 23, 2005 at 04:38 UTC
    Didn't you just say you want encode/decode everything for this table? If you override these in one class/table, it will not affect any others.

      I didn't mean to say that the entire table is encoded, although it looks like what I did say could be read that way. I thought I had said only some columns were encoded. So a straight query might be something like:

      SELECT a, b, DECODE(c, 'foo') AS c
      FROM mytable

      The problem being that not all columns are encoded - otherwise rewriting the fragments would be perfect.

      Sorry about any confusion caused.

        I would try the get/set route then, if duplicating encode in perl is not too bad.