DBD/DBI datetime insert

anyone have the code that will insert the current time into a
datetime field in a table
while using perl DBI/DBD::mysql?

--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules [at] m .gmane.org
Hal Wigoda [ Mo, 04 September 2006 02:23 ] [ ID #1454586 ]

Re: DBD/DBI datetime insert

Hal Wigoda wrote:

> anyone have the code that will insert the current time into a
> datetime field in a table while using perl DBI/DBD::mysql?


Hi,

Hopefully this will give you enough pointers.

--
Kenny

#!/usr/bin/perl -w

use strict;
use DBI;

my $dbh = DBI->connect( "DBI:mysql:test", "root", "");
my $sth = $dbh->prepare( "INSERT INTO a VALUES ( NOW() )" );
$sth->execute();
$sth->finish();

$sth = $dbh->prepare( "SELECT a FROM a" );
$sth->execute();
my ( $time ) = $sth->fetchrow_array();
$sth->finish();

print "The time was [$time]\n";

$dbh->disconnect();

__END__

CREATE TABLE a (
a datetime NOT NULL default '0000-00-00 00:00:00'
) TYPE=MyISAM;



--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules [at] m .gmane.org
Kenny Scott [ Mo, 04 September 2006 15:15 ] [ ID #1454587 ]
Datenbanken » gmane.comp.db.mysql.perl » DBD/DBI datetime insert

Vorheriges Thema: handling with variable
Nächstes Thema: Patch to allow dashes in table names