README
1
2DBIx::Browse - Module to browse related tables.
3(c) Copyright 2000 Evilio Jos� del R�o Silv�n <edelrio@icm.csic.es>
4
5
6This program is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2 of the License, or
9any later version.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with this program; if not, write to the Free Software
18Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19
20
21
22Description
23-----------
24
25DBIx::Browse is a module to facilitate the browsing (INSERT,
26UPDATE and DELETE) of related database tables.
27
28Build and Install
29-----------------
30
31All you have to do to build, test and install this stuff, if your
32connected to the Internet, is:
33
34perl Makefile.PL
35make
36make test
37make install
38
39NOTE: To perform all tests, including inserting, updating and deleting
40some rows, you need to set two environment variables:
41
42DBI_DSN : The DBI(3) default Data Source Name (see DBI(3)).
43
44DBIX_BROWSE_MAKE_TEST : If set to some true value, the tests will be performed.
45
46These tests expect to find in the databese pointed by DBI_DSN two
47tables as described by the examples/test.psql. This file is written in
48Postgres dialect but can be adapted easily to others (I also provide
49the examples/test.mysql for MySQL). Be careful since the operations
50performed by the tests could destroy some valuable information (that's
51why I require special environment variables to be set before
52connecting to DBI).
53
54For example, in a Unix box with Postgres installed locally you should do
55something like that:
56
57# Optionally, create a test database
58$ createdb --host localhost --user john test
59# ...
60# Create the tables
61$ psql --host localhost --user john -f examples/test.psql test
62# ...
63# Setup environment
64$ setenv DBI_DSN "dbi:Pg:database=test;host=localhost;user=john;password=doe"
65$ setenv DBIX_BROWSE_MAKE_TEST 1
66# ...
67# Make tests
68$ make test
69# ...
70#
71# Optionally, destroy the test database
72$ dropdb --host localhost --user john test
73
74
75Usage Overview
76--------------
77
78
79 use DBIx::Browse;
80 my ($dbh, $dbb, $q);
81 $dbh = DBI->connect("DBI:Pg:dbname=enterprise")
82 or croak "Can't connect to database: $@";
83 $dbb = new DBIx::Browse({
84 dbh => $dbh,
85 table => 'employee',
86 proper_fields => [ qw ( name fname ) ],
87 linked_fields => [ qw ( department category office ) ],
88 linked_tables => [ qw ( department category office ) ],
89 linked_values => [ qw ( name name phone ) ],
90 linked_refs => [ qw ( id id id ) ],
91 aliases => [ qw ( name fname department category phone )],
92 primary_key => 'id'
93 });
94
95
96 $my $sth = $db->prepare({
97 where => "departament = 'Adminitstration' AND age < 35",
98 order => "name ASC, departament ASC"
99 }
100
101
102 $dbb->insert({
103 name => 'Doe',
104 fname => 'John',
105 department => 'Sales',
106 category => 'Sales representatn',
107 phone => '1114'
108 });
109
110 $dbb->update({
111 category => 'Sales manager',
112 phone => '1113'
113 },
114 " id = 1 "
115 );
116
117
118 ...etc
119
120
121
122Examples
123--------
124
125See the directory examples and the test directory scripts of the
126distribution.
127
128
129Author
130------
131
132Evilio Jos� del R�o Silv�n <edelrio@icm.csic.es>
133
134
135
136
137
138
139