Name
Object::Relation::Handle::DB::SQLite::DBI - DBI subclass adding funtions to SQLite
Synopsis
my $dbh = Object::Relation::Handle::DB::SQLite::DBI->connect(...);
Description
This class subclasses the DBI to add custom functions and aggregates to the SQLite interface. These functions can then simply be used in SQLite queries.
Interface
Functions
coll_set
SELECT coll_set('blog_entry', 1, 'tag', '3,14,12,56,2,33');
This function sets all of the objects in a collection. Think @coll = (@ids)
. Any pre-existing objects in the collection that are not in the new list of objects will be discarded. Existing objects that are in the new list will remain in the same row in the database, but may have their order column updated as appropriate. In the above example, the tag collection associated with blog entry ID 1 will contain the tags with the IDs 3, 14, 12, 56, 2, and 33 in that order.
coll_add
SELECT coll_add('blog_entry', 1, 'tag', '4,3,5,14');
This function adds a list of objects to a collection. Think push @coll, @ids
. Any existing objects in the collection will remain unmolested. If any of the IDs to be added already exist in the collection, they will remain in the same row and will retain their existing ordering. Otherwise, new IDs will be added, with their ordering starting with the next number after the highest order number currently stored in the database for the object.
In the above example, the tag IDs 4, 3, 5, and 14 will be added in that order to the collection for the blog entry with the ID 1.
coll_del
SELECT coll_del('blog_entry', 1, 'tag', '3,12,56,2');
This function deletes a specific list of objects from a collection. Think delete @coll{@ids}
. In the above exmple, it would delete the tags with the IDs 3, 12, 56, and 2 from the collection of tags associated with the blog entry with the ID 1.
coll_clear
SELECT coll_clear('blog_entry', 1, 'tag');
This function clears a collection from the datatabse. Think @coll = ()
. In the above example, it would delete all of the tags in the collection of tags associated with the blog entry with the ID 1.
UUID_V4
SELECT UUID_V4();
This function uses the create_uuid()
function from Object::Relation::Functions to create a new UUID.
regexp
SELECT regexp('^foo', 'food');
SELECT name, rank
FROM soldier
WHERE name REGEXP '^Larry';
This function adds the full power of Perl regular expresions to SQLite. The regular expression is the first argument, and the string to be matched against is the second argument. All comparisons are case-insensitive.
Conveniently, the mere presence of this function allows the SQLite REGEXP
operator to work, as well. See http://www.justatheory.com/computers/databases/sqlite/add_regexen.html.
isa_gtin
SELECT isa_gtin('4007630000116');
Examines the value passed to it to determine whether or not it is a valid GTIN. Imported from Object::Relation::Functions.
Methods
connected
Copyright and License
Copyright (c) 2004-2006 Kineticode, Inc. <info@obj_relode.com>
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.