[EMAIL PROTECTED] wrote:
[EMAIL PROTECTED]

I am working on learning Apache::ASP and came across some issues with
the "MyBookmarks" example as shown on
http://www.apache-asp.org/articles/perlmonth2_build.html:

1.  I received the following warning in my Apache error log on every
    hit:

[Thu Feb 12 00:25:22 2004] [error] [asp] [12691] [debug] $Response->Expi
res() deprecated.  Please access member directly with $Response->{Expire
s} notation


That's right! The My Bookmarks application probably predates that API change. Thanks for pointing this out, I'll updated this in a future release of Apache::ASP, as the My Bookmarks sample app is part of the Apache::ASP distribution at ./site/apps/bookmarks

42c42
<     $Response->Expires(0);
---

$Response->{Expires} = 0;

Yep, this was the fix.




2. My table of links was showing up empty on the bookmarks.asp page.

    The problem was that the column names in the @bookmarks array of
    hashrefs were uppercase, but the table generation code was using
    lower case keys.

Here is the CSV file:

<CVSENV>[EMAIL PROTECTED]:~# cat /tmp/asp_apps_bookmarks/bookmarks
BOOKMARK_ID,USERNAME,TITLE,URL

I am not sure why your CSV file gets created with uppercase columns. I just tried the application and mine created the columns with lowercase names in the CSV file. I had the same version of DBD::CSV, but a more recent DBI module. A complete work around to this problem is to not rely on the returned column names at all ... here is a diff that makes this happen:

--- bookmarks/bookmarks.asp     12 Sep 2002 20:05:55 -0000      1.1.1.1
+++ bookmarks/bookmarks.asp     14 Feb 2004 02:00:52 -0000
@@ -62,14 +62,20 @@

 # get all the bookmarks
 ERROR:
-my $sth = $Db->prepare_cached(
-                       "select * from bookmarks where username=? ".
-                       "order by bookmark_id"
+my $rows = $Db->selectall_arrayref(
+                       "select bookmark_id, username, title, url from bookmarks where 
username=? ".
+                       "order by bookmark_id",
+                       undef,
+                       $Session->{'user'}
                        );
-$sth->execute($Session->{'user'});
 my @bookmarks;
-while(my $bookmark = $sth->fetchrow_hashref()) {
-       push(@bookmarks, $bookmark);
+for my $row ( @$rows ) {
+       push(@bookmarks, {
+               bookmark_id => $row->[0],
+               username => $row->[1],
+               title => $row->[2],
+               url => $row->[3],
+               });
 }
 %>

Actually, not relying on the column names case is probably a good idea long
term.  It seems that each database has a different way of returning column
names, so for portability its best to use columns by positional reference only.
Oracle returns uppercase, MySQL returns as defined (mixed lower/upper), &
I think PostgreSQL return all lowercase ( could be wrong on this. ).

I'll update the app bundled with Apache::ASP, but will leave the article as is.
It was published in 1999 after all, and pretty much works still anyway.

Regards,

Josh
________________________________________________________________________
Josh Chamas, Founder    | NodeWorks - http://www.nodeworks.com
Chamas Enterprises Inc. | NodeWorks Directory - http://dir.nodeworks.com
http://www.chamas.com   | Apache::ASP - http://www.apache-asp.org



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to