From 57c2e01b13d7a72c30a534adadb52b48ca99a4fb Mon Sep 17 00:00:00 2001 From: josch Date: Thu, 11 Oct 2007 22:55:07 +0000 Subject: [PATCH] added timestamps to videos git-svn-id: http://yolanda.mister-muffin.de/svn@42 7eef14d0-6ed0-489d-bf55-20463b2d70db --- trunk/init_sql.pl | 2 +- trunk/search.pl | 5 +++-- trunk/uploader.pl | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/trunk/init_sql.pl b/trunk/init_sql.pl index 5672885..638931c 100644 --- a/trunk/init_sql.pl +++ b/trunk/init_sql.pl @@ -19,7 +19,7 @@ $dbh->do(qq{insert into tagcloud values ('web tv', 68)}); $dbh->do(qq{create table users (id int auto_increment not null, username varchar(255) not null, password char(41) not null, sid char(32) not null, primary key (id))}); -$dbh->do(qq{create table videos (id int auto_increment not null, title varchar(255) not null, caption text, userid varchar(255) not null, hash char(64) not null, status int not null, primary key (id), fulltext (title, caption))}); +$dbh->do(qq{create table videos (id int auto_increment not null, title varchar(255) not null, caption text not null, userid varchar(255) not null, hash char(64) not null, status int not null, timestamp datetime not null, primary key (id), fulltext (title, caption))}); $dbh->disconnect() or die $dbh->errstr; diff --git a/trunk/search.pl b/trunk/search.pl index 2d0e2ee..b990314 100644 --- a/trunk/search.pl +++ b/trunk/search.pl @@ -22,13 +22,13 @@ if($query->param('query')) my $dbh = DBI->connect("DBI:mysql:$database:$dbhost", $dbuser, $dbpass) or die $dbh->errstr; #prepare query - my $sth = $dbh->prepare(qq{select title, caption from videos where match(title, caption) against('$search_query') }) or die $dbh->errstr; + my $sth = $dbh->prepare(qq{select title, caption, timestamp from videos where match(title, caption) against('$search_query') }) or die $dbh->errstr; #execute it $sth->execute() or die $dbh->errstr; #get every returned value - while (my ($title, $caption) = $sth->fetchrow_array()) + while (my ($title, $caption, $timestamp) = $sth->fetchrow_array()) { #really obfuscated array/hash creation push @{ $page->{'results'}->{'result'} }, @@ -40,6 +40,7 @@ if($query->param('query')) { 'rdf:about' => './videos/1050x700/4chan_city_mashup.ogg', 'dc:title' => [$title] + 'dc:date' => [$timestamp] }, 'cc:License' => { diff --git a/trunk/uploader.pl b/trunk/uploader.pl index e6c8c88..967c1c9 100644 --- a/trunk/uploader.pl +++ b/trunk/uploader.pl @@ -35,7 +35,7 @@ if($userid) # 3 - error: was not a valid video/format # 4 - error: video is a duplicate #do query - $dbh->do(qq{insert into videos (title, caption, userid, status) values ('$title', '$caption', '$userid', 0)}) or die $dbh->errstr; + $dbh->do(qq{insert into videos (title, caption, userid, status, timestamp) values ('$title', '$caption', '$userid', 0, now())}) or die $dbh->errstr; #prepare query my $sth = $dbh->prepare(qq{select last_insert_id() }) or die $dbh->errstr;