DBIx::DataModel::Doc::Internals - Description of the internal structure
This chapter is part of the DBIx::DataModel manual.
DBIx::DataModel
SYNOPSIS AND DESCRIPTION
DESIGN
QUICKSTART
REFERENCE
MISC
INTERNALS
GLOSSARY
This chapter documents some details that normally should not be relevant to clients; you only want to read about them if you intend to extend the framework.
DBIx::DataModel::Base->_setClassData($subclass, $data_ref);
DBIx::DataModel::Schema->_createPackage($pckName, $isa_arrayref);
Creates a new Perl package of name $pckName that inherits from @$isa_arrayref. Raises an exception if the package name already exists.
$pckName
@$isa_arrayref
DBIx::DataModel::Schema ->_defineMethod($pckName, $methName, $coderef, $silent);
Defines a new method in package $pckName, bound to $coderef; or undefines a method if $coderef is undef. Raises an exception if the method name already exists in that package. Generates a warning if the method name already exists in a parent class, unless the optional $silent argument is true.
$coderef
undef
$silent
$obj->_rawInsert(%options);
Internal implementation for insertions into the database : takes keys and values within %$obj, generates SQL for insertion of those values into $obj->dbTable, and executes it. Never called directly, but used by the protected method _singleInsert.
%$obj
$obj->dbTable
The optional %options argument can contain one single key : -returning. If that option is present, and the value is either a scalar or an arrayref, then it will be passed as an option to "insert" in SQL::Abstract, and the returned value(s) will be fetched from the sth and returned to the caller.
%options
-returning
$obj->_singleInsert(%options);
Implementation for inserting a record into the database; should never be called directly, but is used as a backend by the insert method.
This method receives an object blessed into some table class; the object hash should only contain keys and values to be directly inserted into the database, i.e. the noUpdateColumns and all references to foreign objects should have been removed ( normally the insert method has already done that job). The _singleInsert method calls "_rawInsert" for performing the database update, and then makes sure that the object contains its own key, calling DBI's last_insert_id() if necessary, as explained in the insert documentation.
noUpdateColumns
_singleInsert
You may redeclare _singleInsert in your own table classes, for example if you need to compute a key by other means, like constructing it from other fields, or generating it from a random number.
The return value from _singleInsert depends on %options :
if $options{-returning} is a scalar or arrayref, that option is passed to _rowInsert, then to "insert" in SQL::Abstract and finally to the SQL level (INSERT ... RETURNING ...); whatever is returned from the database gets transmitted back to the caller.
$options{-returning}
_rowInsert
if $options{-returning} is a hashref, the return value is also a hashref, containing the column name(s) and value(s) of the primary key for that record
if $options{-returning} is absent, the return value is the list of values of the primary key for that record.
To install DBIx::DataModel, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DBIx::DataModel
CPAN shell
perl -MCPAN -e shell install DBIx::DataModel
For more information on module installation, please visit the detailed CPAN module installation guide.