Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re^3: Can DBI modify queries on the fly?

by ikegami (Pope)
on Feb 18, 2009 at 02:19 UTC ( #744616=note: print w/replies, xml ) Need Help??

in reply to Re^2: Can DBI modify queries on the fly?
in thread Can DBI modify queries on the fly?

That refers to modifying @_ only, not modifying copies of what's in @_ or SQL placeholders

Replies are listed 'Best First'.
Re^4: Can DBI modify queries on the fly?
by kyle (Abbot) on Feb 18, 2009 at 17:01 UTC

    That's kind of the whole point, though, isn't it? The callback can't return any values. The only way to make any changes to what's going on is to modify the parameters directly. Or am I missing something?

    As such, you have to worry about changing the application's data under its nose. You also have to watch out for the case where you're passed a read-only value.

      What does modifying variables in the caller got to do with overriding a method? You haven't specified why you want to override the method, but I'm guessing "the point" is to change the values passed to your override then call the original method. How does modifying a variable that probably won't ever be used again help you?

        The callback functionality that perrin referred to does not override the method. Instead, I can insert a callback that is called before the real method. The callback is not allowed to return any value (doing so causes an exception).

        The only way to modify the behavior of the original method is to change the parameters that it gets. To do that, I have to change (the contents of) @_. The side effect is that the original method's caller has its data changed also. The other problem I see is that I won't be allowed to do this at all if the parameter I'm interested in (the query) is a read-only value as in:

        my ($count) = $dbh->selectrow_array( 'SELECT count(*) FROM table' );

        Both of those are serious enough to make me want to go back to looking at some DBD subclass with an overridden method instead of using the callback, but I'm not sure it will be worth the effort.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://744616]
Discipulus bad people + good tool < normal people + decent tool
[Discipulus]: php does not suck anymore?
[ambrus]: Discipulus: I'm not sure, but it certainly doesn't suck as much as it's used to. it's like C++, it sucks because people still recursively learn from twenty year old PHP examples,
[ambrus]: and they try to use the obsolete features that PHP has to support only for compatibility with old scripts. C++ and PHP both have the problem that people can't forget the past, because when they google "PHP" plus the problme they want to solve, they find b
[ambrus]: ad code examples.
[ambrus]: I'm not trying to recommend PHP, but I think it has way too bad a name because of its past.
[ambrus]: This is different from MS Word, which was already a good editor in the pre-unicode days (in word for windows versions 2 and 6, which ran on windows 3 but also on windows 95), only it wasn't trying to solve the task of writing maths papers back then.
[Discipulus]: ah ok, sounds reasonable; with no fear: Perl all life long
[ambrus]: Mind you, LaTeX is currently still useful for writing math paper or snippet content without styling in such a way that the
[ambrus]: formatting conventions of a journal or website can be quickly applied to it, and MS Office and LibreOffice has not quite solved this (although it's better for this than it used to be),

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (11)
As of 2017-09-26 11:10 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (293 votes). Check out past polls.