| 1 | ################################################################################ |
1 | ################################################################################ |
| 2 | # WeBWorK Online Homework Delivery System |
2 | # WeBWorK Online Homework Delivery System |
| 3 | # Copyright © 2000-2006 The WeBWorK Project, http://openwebwork.sf.net/ |
3 | # Copyright © 2000-2006 The WeBWorK Project, http://openwebwork.sf.net/ |
| 4 | # $CVSHeader: webwork2/lib/WeBWorK/DB/Schema/SQL.pm,v 1.29 2005/08/30 05:49:59 jj Exp $ |
4 | # $CVSHeader$ |
| 5 | # |
5 | # |
| 6 | # This program is free software; you can redistribute it and/or modify it under |
6 | # This program is free software; you can redistribute it and/or modify it under |
| 7 | # the terms of either: (a) the GNU General Public License as published by the |
7 | # the terms of either: (a) the GNU General Public License as published by the |
| 8 | # Free Software Foundation; either version 2, or (at your option) any later |
8 | # Free Software Foundation; either version 2, or (at your option) any later |
| 9 | # version, or (b) the "Artistic License" which comes with this package. |
9 | # version, or (b) the "Artistic License" which comes with this package. |
| … | |
… | |
| 217 | croak "wrong number of keyparts for table $table (needs: @keynames)" |
217 | croak "wrong number of keyparts for table $table (needs: @keynames)" |
| 218 | unless @keyparts == @keynames; |
218 | unless @keyparts == @keynames; |
| 219 | |
219 | |
| 220 | my ($where, @where_args) = $self->makeWhereClause(@keyparts); |
220 | my ($where, @where_args) = $self->makeWhereClause(@keyparts); |
| 221 | |
221 | |
|
|
222 | my $fieldnames = join(", ", $self->sqlFieldnames); |
| 222 | my $stmt = "SELECT * FROM `$sqlTable` $where"; |
223 | my $stmt = "SELECT $fieldnames FROM `$sqlTable` $where"; |
| 223 | $self->debug("SQL-gets: $stmt\n"); |
224 | $self->debug("SQL-gets: $stmt\n"); |
| 224 | |
225 | |
| 225 | my $sth = $self->{driver}->dbi()->prepare($stmt); |
226 | my $sth = $self->{driver}->dbi()->prepare($stmt); |
| 226 | $sth->execute(@where_args); |
227 | $sth->execute(@where_args); |
| 227 | my $result = $sth->fetchrow_arrayref; |
228 | my $result = $sth->fetchrow_arrayref; |
| … | |
… | |
| 261 | my @keynames = $self->sqlKeynames(); |
262 | my @keynames = $self->sqlKeynames(); |
| 262 | pop @keynames; # get rid of problem_id |
263 | pop @keynames; # get rid of problem_id |
| 263 | |
264 | |
| 264 | my ($where, @where_args) = $self->makeWhereClause(@keyparts); |
265 | my ($where, @where_args) = $self->makeWhereClause(@keyparts); |
| 265 | |
266 | |
|
|
267 | my $fieldnames = join(", ", $self->sqlFieldnames); |
| 266 | my $stmt = "SELECT * FROM `$sqlTable` $where"; |
268 | my $stmt = "SELECT $fieldnames FROM `$sqlTable` $where"; |
| 267 | $self->debug("SQL-getAll: $stmt\n"); |
269 | $self->debug("SQL-getAll: $stmt\n"); |
| 268 | |
270 | |
| 269 | my @records; |
271 | my @records; |
| 270 | |
272 | |
| 271 | $self->{driver}->connect("ro"); |
273 | $self->{driver}->connect("ro"); |