NAME
DBD::XBase - DBI driver for XBase compatible database files
SYNOPSIS
use DBI;
my $dbh = DBI->connect("DBI:XBase:/directory/subdir")
or die $DBI::errstr;
my $sth = $dbh->prepare("select MSG from test where ID != 1")
or die $dbh->errstr();
$sth->execute() or die $sth->errstr();
my @data;
while (@data = $sth->fetchrow_array())
{ ## further processing }
$dbh->do('update table set name = ? where id = 45', {}, 'krtek');
DESCRIPTION
DBI compliant driver for module XBase. Please refer to DBI(3) documentation for how to actually use the module. In the connect call, specify the directory containing the dbf files (and other, memo, etc.) as the third part of the connect string. It defaults to the current directory.
Note that with dbf, there is no database server that the driver would talk to. This DBD::XBase calls methods from XBase.pm module to read and write the files on the disk directly, so any limitations and features of XBase.pm apply to DBD::XBase as well. DBD::XBase basically adds SQL, DBI compliant interface to XBase.pm.
The DBD::XBase doesn't make use of index files at the moment. If you really need indexed access, check XBase(3) for notes about ndx support.
SUPPORTED SQL COMMANDS
The SQL commands currently supported by DBD::XBase's prepare are:
select
select fields from table [ where condition ]
[ order by field ]
Fields is a comma separated list of fields or a *
for all. The where
condition specifies which rows will be returned, you can have arbitrary arithmetic and boolean expression here, compare fields and constants and use and
and or
. Match using like
is also supported. Examples:
select * from salaries where name = "Smith"
select first,last from people where login = "ftp"
or uid = 1324
select id,first_name,last_name from employ
where last_name like 'Ki%'
select id,name from employ where id = ?
You can use bind parameters in the where clause, as the last example shows. The actual value has to be supplied via bind_param or in the call to execute or do, see DBI(3) for details. To check for NULL values in the where
expression, use id is null
and id is not null
, not id == null
.
delete
delete from table [ where condition ]
The where
condition is the same as for select. Examples:
delete from jobs ## emties the table
delete from jobs where companyid = "ISW"
delete from jobs where id < ?
insert
insert into table [ ( fields ) ] values ( list of values )
Here fields is a (optional) comma separated list of fields to set, list of values is a list of constants to assign. If the fields are not specified, sets the fields in the natural order of the table. You can use bind parameters in the list of values. Examples:
insert into accounts (login, uid) values ("guest", 65534)
insert into accounts (login, uid) values (?, ?)
insert into passwd values ("user","*",4523,100,"Nice user",
"/home/user","/bin/bash")
update
update table set field = new value [ , set more fields ]
[ where condition ]
Example:
update passwd set uid = 65534 where login = "guest"
update zvirata set name = "Jezek", age = 4 where id = 17
Again, the value can also be specified as bind parameter.
update zvirata set name = ?, age = ? where id = ?
create table
create table table name ( columns specification )
Columns specification is a comma separated list of column names and types. Example:
create table rooms ( roomid int, cat char(10), balcony boolean )
The allowed types are
char num numeric int integer float boolean blob memo date time
datetime
Some of them are synonyms. They are of course converted to appropriate XBase types.
drop table
drop table table name
Example:
drop table passwd
VERSION
0.140
AUTHOR
(c) 1997--1999 Jan Pazdziora, adelton@fi.muni.cz, http://www.fi.muni.cz/~adelton/ at Faculty of Informatics, Masaryk University in Brno, Czech Republic
SEE ALSO
perl(1); DBI(3), XBase(3)