My favorites | Sign in
Project Home
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl DBD-Yahoo.t'

#########################

# change 'tests => 1' to 'tests => last_test_to_print';

use Test;
BEGIN { plan tests => 7 };
use DBD::Yahoo;
ok(1); # If we made it this far, we're ok.

my $appid = "YahooTaiwanHackday20070209";
my %opts = ("Count" => 3);
my $dbh = DBI->connect("dbi:Yahoo:", $appid, undef, \%opts);
my $q = "yahoo";

# it can handle the fixed statement with specific fields
my $sth1 = $dbh->prepare(qq[SELECT title, url FROM yahoo WHERE Doc = "$q"]);
$sth1->execute;
ok($sth1->rows == 3);
ok($sth1->fetchrow_hashref->{URL} eq 'http://yahoo.com/');

# it can get all fields available, and bind paramater dymanically
my $sth2 = $dbh->prepare(qq[SELECT * FROM yahoo WHERE Doc = ?]);
$sth2->bind_param(1, $q);
$sth2->execute;
ok($sth2->rows == 3);
ok($sth2->fetchrow_hashref->{URL} eq 'http://yahoo.com/');

# it supports MySQL-like offset and limit
my $sth3 = $dbh->prepare(qq[SELECT * FROM yahoo WHERE Doc = ? LIMIT 1, 4]);
$sth3->execute($q);
ok($sth3->rows == 4);
ok($sth3->fetchrow_hashref->{URL} eq 'http://mail.yahoo.com/');

Change log

r9 by leeym112 on Apr 2, 2008   Diff
add DBD-Yahoo
Go to: 
Project members, sign in to write a code review

Older revisions

All revisions of this file

File info

Size: 1197 bytes, 35 lines
Powered by Google Project Hosting