Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: DBI, and date type SQLite

by CountZero (Bishop)
on Oct 09, 2011 at 21:24 UTC ( [id://930497]=note: print w/replies, xml ) Need Help??


in reply to DBI, and date type SQLite

Did you try juliandays(?) in that SQL? And if you did, what was the result?

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Replies are listed 'Best First'.
Re^2: DBI, and date type SQLite
by nando (Acolyte) on Oct 09, 2011 at 21:46 UTC

    Hello and thanks!

    It's the first thing I tried:

    ... + + ...and julianday( ? ) between julianday ( inicio_reserva ) and juliand +ay ( fin_reserva ) order by ?)) or die "No puedo preparar la sentenci +a: " .$dbh->errstr; my @data; $sth->execute("$fecha","$orden") or die "Algo está pasando... ¡Llama a + los bomberos!: " . $sth->errstr;

    Apache says:

    [Sun Oct 09 23:39:14 2011] [error] [client 127.0.0.1] closing dbh with active statement handles at /Library/WebServer/CGI-Executables/ini.cgi line 141., referer: http://127.0.0.1/~net/index.html

    Line 141 is

    $dbh->disconnect;

    And CGI prints table head's but none result

      So, you didn't show us the part where you call ->fetchrow or ->fetchall. The warning means that you didn't fetch all rows. Maybe you meant to do that, but you don't show the part of your code that relates to that warning at all.

        Thanks!... The code is:

        use CGI; use DBI; use Encode; my $q = CGI->new; my $fecha= $q->param('theDate'); my $orden= $q->param('orden'); print $q->header, $q->start_html(-lang=>'es-SP',-title=> 'Reservas CPA +'), $q->h2({-align=>'CENTER'},decode("utf-8","Reservas para el día: " +)."$fecha ordenadas por $orden\n\n"); my $dbh = DBI->connect("dbi:SQLite:dbname=cpa-simple.db", "", "", {Rai +seError =>1 } ); my $sth = $dbh->prepare( q ( select id_reserva,activo,tipo_reserva,ent +idad_nombre_reserva,nombre,apellidos,telefono,inicio_reserva,fin_rese +rva,periodicidad,horai,horaf,nombre_admin from reserva,activos,nombre +,administ where reserva.ac\ tivos_reserva_id=activos.id_activos and reserva.nombre_reserva_id=nomb +re.id_dni and reserva.administ_reserva_id=administ.id_administ and ju +lianday( ? ) between julianday ( inicio_reserva ) and julianday ( fin +_reserva ) order by ?)) or\ die "No puedo preparar la sentencia: " .$dbh->errstr; my @data; $sth->execute("$fecha","$orden") or die "Algo está pasando... ¡Llama a + los bomberos!: " . $sth->errstr; my @datautf8; print $q->start_table({-border=>'1', -align=>'center',-cellpadding=>'6'} +),"\n\n", $q->start_Tr, $q->start_td({align=>'center'}),"\n", $q->p(decode("utf-8","Núm.")),"\n", $q->end_td, "\n", $q->start_td({align=>'center'}),"\n", $q->p(decode("utf-8","Material")),"\n", $q->end_td, "\n", $q->start_td({align=>'center'}),"\n", $q->p(decode("utf-8","Carácter")),"\n", $q->end_td, "\n", $q->start_td({align=>'center'}),"\n", $q->p(decode("utf-8","Entidad")),"\n", $q->end_td, "\n", $q->start_td({align=>'center'}),"\n", $q->p(decode("utf-8","Nombre")),"\n", $q->end_td, "\n", $q->start_td({align=>'center'}),"\n", $q->p(decode("utf-8","Apellidos")),"\n", $q->end_td, "\n", $q->start_td({align=>'center'}),"\n", $q->p(decode("utf-8","Teléfono")),"\n", $q->end_td, "\n", $q->start_td({align=>'center'}),"\n", $q->p(decode("utf-8","Inicio de reserva")),"\n", $q->end_td, "\n", $q->start_td({align=>'center'}),"\n", $q->p(decode("utf-8","Fin de reserva")),"\n", $q->end_td, "\n", $q->start_td({align=>'center'}),"\n", $q->p(decode("utf-8","Periódica")),"\n", $q->end_td, "\n", $q->start_td({align=>'center'}),"\n", $q->p(decode("utf-8","Hora inicio")),"\n", $q->end_td, "\n", $q->start_td({align=>'center'}),"\n", $q->p(decode("utf-8","Hora finalización")),"\n", $q->end_td, "\n", $q->start_td({align=>'center'}),"\n", $q->p(decode("utf-8","Administrador")),"\n", $q->end_td, "\n", $q->end_Tr,"\n"; while ( @data = $sth->fetchrow_array()){ @datautf8 = map(decode("utf-8",$_), @data); print $q->start_Tr, $q->start_td({-align=>'left'}),"\n", $q->p("$datautf8[0]"),"\n", $q->end_td,"\n", $q->start_td({-align=>'left'}),"\n", $q->p("$datautf8[1]"),"\n", $q->end_td,"\n", $q->start_td({-align=>'left'}),"\n", $q->p("$datautf8[2]"),"\n", $q->end_td,"\n", $q->start_td({-align=>'left'}),"\n", $q->p("$datautf8[3]"),"\n", $q->end_td,"\n", $q->start_td({-align=>'left'}),"\n", $q->p("$datautf8[4]"),"\n", $q->end_td,"\n", $q->start_td({-align=>'left'}),"\n", $q->p("$datautf8[5]"),"\n", $q->end_td,"\n", $q->start_td({-align=>'left'}),"\n", $q->p("$datautf8[6]"),"\n", $q->end_td,"\n", $q->start_td({-align=>'left'}),"\n", $q->p("$datautf8[7]"),"\n", $q->end_td,"\n", $q->start_td({-align=>'left'}),"\n", $q->p("$datautf8[8]"),"\n", $q->end_td,"\n", $q->start_td({-align=>'left'}),"\n", $q->p("$datautf8[9]"),"\n", $q->end_td,"\n", $q->start_td({-align=>'left'}),"\n", $q->p("$datautf8[10]"),"\n", $q->end_td,"\n", $q->start_td({-align=>'left'}),"\n", $q->p("$datautf8[11]"),"\n", $q->end_td,"\n", $q->start_td({-align=>'left'}),"\n", $q->p("$datautf8[12]"),"\n", $q->end_td,"\n", $q->start_td({-align=>'left'}),"\n", $q->p("$datautf8[13]"),"\n", $q->end_td,"\n", $q->end_Tr,"\n\n"; } $q->end_table; print $q->end_html; $sth->finish; $dbh->disconnect; exit 0;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://930497]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2024-03-29 08:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found