… | |
… | |
166 | } |
166 | } |
167 | } |
167 | } |
168 | |
168 | |
169 | static GV *sql_exec; |
169 | static GV *sql_exec; |
170 | static GV *DBH; |
170 | static GV *DBH; |
171 | static SV *sv_prepare, *sv_execute, *sv_bind_columns, *sv_fetchrow_arrayref, *sv_finish; |
171 | static SV *sv_prepare, *sv_execute, *sv_bind_columns, |
|
|
172 | *sv_fetchrow_arrayref, *sv_fetchall_arrayref, |
|
|
173 | *sv_finish; |
172 | |
174 | |
173 | #define newconstpv(str) newSVpvn ((str), sizeof (str)) |
175 | #define newconstpv(str) newSVpvn ((str), sizeof (str)) |
174 | |
176 | |
175 | MODULE = PApp::SQL PACKAGE = PApp::SQL |
177 | MODULE = PApp::SQL PACKAGE = PApp::SQL |
176 | |
178 | |
… | |
… | |
185 | { |
187 | { |
186 | sv_prepare = newconstpv ("prepare"); |
188 | sv_prepare = newconstpv ("prepare"); |
187 | sv_execute = newconstpv ("execute"); |
189 | sv_execute = newconstpv ("execute"); |
188 | sv_bind_columns = newconstpv ("bind_columns"); |
190 | sv_bind_columns = newconstpv ("bind_columns"); |
189 | sv_fetchrow_arrayref = newconstpv ("fetchrow_arrayref"); |
191 | sv_fetchrow_arrayref = newconstpv ("fetchrow_arrayref"); |
|
|
192 | sv_fetchall_arrayref = newconstpv ("fetchall_arrayref"); |
190 | sv_finish = newconstpv ("finish"); |
193 | sv_finish = newconstpv ("finish"); |
191 | } |
194 | } |
192 | |
195 | |
193 | /* apache might BOOT: twice :( */ |
196 | /* apache might BOOT: twice :( */ |
194 | if (lru_size) |
197 | if (lru_size) |
… | |
… | |
401 | SV *rows; |
404 | SV *rows; |
402 | |
405 | |
403 | PUSHMARK (SP); |
406 | PUSHMARK (SP); |
404 | XPUSHs (sth); |
407 | XPUSHs (sth); |
405 | PUTBACK; |
408 | PUTBACK; |
406 | count = call_sv (sv_fetchrow_arrayref, G_METHOD | G_SCALAR); |
409 | count = call_sv (sv_fetchall_arrayref, G_METHOD | G_SCALAR); |
407 | SPAGAIN; |
410 | SPAGAIN; |
408 | |
411 | |
409 | if (count != 1) |
412 | if (count != 1) |
410 | abort (); |
413 | abort (); |
411 | |
414 | |
… | |
… | |
416 | AV *av = (AV *)SvRV (rows); |
419 | AV *av = (AV *)SvRV (rows); |
417 | count = AvFILL (av) + 1; |
420 | count = AvFILL (av) + 1; |
418 | |
421 | |
419 | if (count) |
422 | if (count) |
420 | { |
423 | { |
421 | int columns = AvFILL ((AV *)SvRV (AvARRAY(av)[0])) + 1; /* columns? */ |
424 | int columns = AvFILL ((AV *) SvRV (AvARRAY (av)[0])) + 1; /* columns? */ |
422 | |
425 | |
423 | EXTEND (SP, count); |
426 | EXTEND (SP, count); |
424 | if (columns == 1) |
427 | if (columns == 1) |
425 | for (arg = 0; arg < count; arg++) |
428 | for (arg = 0; arg < count; arg++) |
426 | PUSHs (maybe_force_utf8 (ix & 1, AvARRAY ((AV *)SvRV (AvARRAY (av)[arg]))[0])); |
429 | PUSHs (maybe_force_utf8 (ix & 1, AvARRAY ((AV *)SvRV (AvARRAY (av)[arg]))[0])); |