On 22/01/2013 22:57, Andrew Beverley wrote:
Basically, I'd like to update lots of fields in a single database row.
From the subject line I thought you were going to ask how to update
lots of fields in lots of rows in a single query...
Considering a table "table" with primary key columns "pkc
On Jan 24, 2013 7:32 PM, "Greg McCarroll" wrote:
> Perl was never cool, it was the kid that liked wearing a sports coat
> to school with leather patches sewn on the elbows
> as they took style tips from their 'cool' maths teacher.
Oi, I resemble that remark! /me wonders what happened to that coa
On 24 Jan 2013, at 17:15, Paul Makepeace wrote:
So we're using Perl still then? :D
Perl was never cool, it was the kid that liked wearing a sports coat
to school with leather patches sewn on the elbows as they took style
tips from their 'cool' maths teacher.
G.
On Jan 24, 2013 8:48 AM, "Greg McCarroll" wrote:
>
>
>
> No no no, lets just use any language that our process analyst consultant
decides - they can come up with a long winded approach to software
development that will ensure the lack of any possible security holes by
providing long winded documen
No no no, lets just use any language that our process analyst consultant
decides - they can come up with a long winded approach to software development
that will ensure the lack of any possible security holes by providing long
winded documentation to auditors and by selecting whatever language
On 24/01/13 16:00, David Cantrell wrote:
On Thu, Jan 24, 2013 at 04:49:17PM +0100, Abigail wrote:
On Thu, Jan 24, 2013 at 03:38:08PM +, Greg McCarroll wrote:
Tied variables ;-)
Overloaded constants, and not even your place holders are safe.
Stupid language. Let's all use C instead.
No
Why C? Assembly is so much more concise.
On Thu, Jan 24, 2013 at 11:00 AM, David Cantrell wrote:
> On Thu, Jan 24, 2013 at 04:49:17PM +0100, Abigail wrote:
>> On Thu, Jan 24, 2013 at 03:38:08PM +, Greg McCarroll wrote:
>> > Tied variables ;-)
>> Overloaded constants, and not even your place h
On Thu, Jan 24, 2013 at 04:49:17PM +0100, Abigail wrote:
> On Thu, Jan 24, 2013 at 03:38:08PM +, Greg McCarroll wrote:
> > Tied variables ;-)
> Overloaded constants, and not even your place holders are safe.
Stupid language. Let's all use C instead.
--
David Cantrell | Cake Smuggler Extraord
On Thu, Jan 24, 2013 at 03:38:08PM +, Greg McCarroll wrote:
>
> Tied variables ;-)
Overloaded constants, and not even your place holders are safe.
Abigail
Tied variables ;-)
G.
On 24 Jan 2013, at 13:57, Denny wrote:
> You do know what $status contains in the example (so you could hardcore it in
> the SQL anyway). $id is up for grabs though.
>
>
>
> Simon Wilcox wrote:
>
>> On 24/01/2013 03:01, Sam Kington wrote:
>>> I mean, sure, this is s
You do know what $status contains in the example (so you could hardcore it in
the SQL anyway). $id is up for grabs though.
Simon Wilcox wrote:
>On 24/01/2013 03:01, Sam Kington wrote:
>> I mean, sure, this is safe:
>>
>> if ($status eq 'foo') {
>> $dbh->do("UPDATE table SET status='$sta
On 24/01/2013 03:01, Sam Kington wrote:
I mean, sure, this is safe:
if ($status eq 'foo') {
$dbh->do("UPDATE table SET status='$status' WHERE id=$id");
}
Only if you're certain you know what $status and $id contain.
http://xkcd.com/327/
On 23 Jan 2013, at 11:09, Abigail wrote:
> I'd say that dogmas are poor practise.
>
>
> Good practise is actually *knowing* when you should use placeholders,
> and when there's no need.
>
> Because someone who knows can actually be trusted to do variable
> interpolation in places where placeho
On Tue, 2013-01-22 at 22:57 +, Andrew Beverley wrote:
> I've not been developing with Perl for long, so I'd like to know if
> there is a better way of writing the following database query (or is
> there a better place to ask?):
Thanks for the many excellent replies. I'll have a play around wit
Be nice as this list has more to offer than silly pounding on people that
release things onto the CPAN or send unclear emails.
A person asks a question. We give an answer. We can only say so much.
A person can only take on board so much. So we have to make that
answer as good as possible in t
> On 3//1//013 0::1,, J?r?me ?t?v? wrote:
> > Something critical is missing in your code though: quoting:
> >
> > Replace $field = '$hash->{$field}' with " $field
> > =".$dbh->quote($hash->{$field})
This would assume all fields were strings. To do it properly, you would need to
have the metadat
On 23/01/2013 11:09, Abigail wrote:
On Wed, Jan 23, 2013 at 10:53:16AM +, William Blunn wrote:
On 23/01/2013 10:21, Jérôme Étévé wrote:
Something critical is missing in your code though: quoting:
Replace $field = '$hash->{$field}' with " $field
=".$dbh->quote($hash->{$field})
The DBI quot
On Wed, Jan 23, 2013 at 10:53:16AM +, William Blunn wrote:
> On 23/01/2013 10:21, Jérôme Étévé wrote:
>> Something critical is missing in your code though: quoting:
>>
>> Replace $field = '$hash->{$field}' with " $field
>> =".$dbh->quote($hash->{$field})
>>
>> The DBI quote method will 'do th
On 23/01/2013 10:21, Jérôme Étévé wrote:
Something critical is missing in your code though: quoting:
Replace $field = '$hash->{$field}' with " $field
=".$dbh->quote($hash->{$field})
The DBI quote method will 'do the right thing to avoid screwing up
your queries'. http://search.cpan.org/dist/
On 22 January 2013 22:57, Andrew Beverley wrote:
> I've not been developing with Perl for long, so I'd like to know if
> there is a better way of writing the following database query
> my @fields = qw(field1 field2 field3 field4 field5 field6 field7 ... );
> my @updates;
> foreach my $field (@fie
On Tue, Jan 22, 2013 at 10:57:29PM +, Andrew Beverley wrote:
> I've not been developing with Perl for long, so I'd like to know if
> there is a better way of writing the following database query (or is
> there a better place to ask?):
>
>
> my @fields = qw(field1 field2 field3 field4 field5 f
On 23/01/2013 09:52, Mark Overmeer wrote:
* Ruud H.G. van Tol (rv...@isolution.nl) [130123 09:45]:
On 2013-01-23 10:27, William Blunn wrote:
my @fields_to_update = grep { $hash->{$_} } @fields;
Be aware that it skips any false value, like undef, '', '0', 0.
my @fields_to_update = grep defined
On 23/01/2013 09:40, Ruud H.G. van Tol wrote:
On 2013-01-23 10:27, William Blunn wrote:
my @fields_to_update = grep { $hash->{$_} } @fields;
Be aware that it skips any false value, like undef, '', '0', 0.
Absolutely.
I wouldn't usually do a straight truth test on a scalar value myself,
un
* Ruud H.G. van Tol (rv...@isolution.nl) [130123 09:45]:
> On 2013-01-23 10:27, William Blunn wrote:
>
> >my @fields_to_update = grep { $hash->{$_} } @fields;
>
> Be aware that it skips any false value, like undef, '', '0', 0.
my @fields_to_update = grep defined $hash->{$_}, @fields;
But that
On 2013-01-23 10:27, William Blunn wrote:
my @fields_to_update = grep { $hash->{$_} } @fields;
Be aware that it skips any false value, like undef, '', '0', 0.
--
Ruud
On 22/01/2013 22:57, Andrew Beverley wrote:
I've not been developing with Perl for long, so I'd like to know if there is a
better way of writing the following database query (or is there a better place
to ask?):
my @fields = qw(field1 field2 field3 field4 field5 field6 field7 ... );
my @updat
On Tuesday, January 22, 2013, Philip Skinner wrote:
my $qry = $self->dbh->prepare("UPDATE table SET " . join (sort(@fields),
> '=?, ') . " WHERE id=?");
> my $affected = $qry->execute(@hash{sort(keys %hash)}, $id);
I know this is just demoing how to use hash manipulation to get two matched
lists
On Tuesday, January 22, 2013, Andrew Beverley wrote:
is a better way of writing the following database query
With Perl there's always more than one way to do it. Greg's post rightly
recommended ORMs and pointed out that, indeed, DBIx::Class is commonly
considered the current best of breed for g
In this day and age I'd be looking at an ORM[1] layer for such simple changes,
they are almost foolproof until someone is a fool ;-). And they will probably
avoid stupid SQL mistakes that you and I might both make.
And DBIx::Class[2] is the current best of breed, it can also 'reverse
engineer'
Maybe something like:
my $qry = $self->dbh->prepare("UPDATE table SET " . join (sort(@fields),
'=?, ') . " WHERE id=?");
my $affected = $qry->execute(@hash{sort(keys %hash)}, $id);
Though I've had quite a bit to drink.
On 01/22/2013 10:57 PM, Andrew Beverley wrote:
I've not been developing w
I've not been developing with Perl for long, so I'd like to know if
there is a better way of writing the following database query (or is
there a better place to ask?):
my @fields = qw(field1 field2 field3 field4 field5 field6 field7 ... );
my @updates;
foreach my $field (@fields)
{
push @upda
31 matches
Mail list logo