The class DBIx::Cursor represents a cursor for a single Database-table. You can select, update, insert or delete entries in a table easier than creating SQL-statements. It does not use any specific features of any database, so it should work with every DBD-driver.

DBIx::Cursor is not a replacement for DBI, but a add-on. You can use DBI as usual and use SQL-statements as you need.

The method new creates an instance of DBIx::Cursor. It returns a object, which represents a table in the database. It checks, that the table exists, so if you create a cursor for a not existing table, it will die.

$dbh is your connection-handle, you get from DBI.

$table is the tablename, you want to use.

The remaining parameters are the names of your primary key. You can use some alternate unique index as well.

But be aware, that DBIx::Cursor does not check, if the index is ok. It expects, that these columns identify exactly one row.

If you don't provide a key, DBIx::Cursor tries to get one through the $dbh->primary_key-method. But not every driver support this method, so to be compatible you should not use this feature. DBD::Pg, which I use for testing, does not provide one.

Do the actual fetch to the database. On the first call (or after resetting the cursor) it builds the SQL-select statement and fetches the first row. On subsequent calls it uses the statement and fetches subsequent rows.

It returns the fetched data as a hash-reference or - in array-context - the hash or undef when there is no more data availible.