perl5ever has asked for the wisdom of the Perl Monks concerning the following question:
With a Moose object I am passing the value of an object attribute to the execute method of a DBI statement handle, i.e. something like:
where $obj is a Moose object. I've been told by my DBAs that the bind parameter is being treated as a string instead of a number which is causing my query to run slowly. I could fix this by writing:$sth = $dbh->prepare(...); $sth->execute($obj->now);
However, I'm using $obj->now in many places.$sth->execute(0+$obj->now);
Question: How can I declare the 'now' attribute of $obj so that on gets it will ensure that the value returned is a number (or undef). Currently, 'now' is simply defined as:
has now => ( is => 'rw' );
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Moose - ensuring a getter returns a number
by Fletch (Bishop) on Feb 17, 2011 at 16:03 UTC | |
by perl5ever (Pilgrim) on Feb 17, 2011 at 20:40 UTC | |
by stvn (Monsignor) on Feb 18, 2011 at 05:14 UTC | |
Re: Moose - ensuring a getter returns a number
by ikegami (Patriarch) on Feb 17, 2011 at 19:02 UTC |
Back to
Seekers of Perl Wisdom