Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
OpenXPKI::Server::DBI(User Contributed Perl DocumentatOpenXPKI::Server::DBI(3)

Name
       OpenXPKI::Server::DBI - OpenXPKI	database interface

Design
       User ----------------------+
				  |
				  |
	      +----------------- DBI ---------------+
	      |		       /  |  \		    |
	      |		     /	  |    \	    |
	   Object ---->	Hash ----------> SQL ----> DBH ----> Database
		\	     \	  |    /	 /  |
		  \	       \  |  /	       /    |
		    ---------- Schema --------	  Driver

       FIXME: THE EXPIRED HANDLING IS STILL NOT	PORTED FROM THE	OLD CODE.

Functions
   Instance Initialization
       new

       is the constructor. It supports TYPE as general parameter.  The TYPE is
       the last	parameters which is understand by the module itself. It	must
       be a valid OpenXPKI::Server::DBI::Driver	class name. All	other
       parameters are directly handled by the corresponding drivers. The
       following parameters are	supported:

       o   HOST

       o   PORT

       o   NAME

       o   USER

       o   PASSWD

       o   NAMESPACE

       o   SERVER_ID

       o   SERVER_SHIFT

       Please remember that not	all drivers can	handle all parameters.

       get_driver_name

       returns the name	of driver.  This is actually necessary for
       OpenXPKI::Server::Log::Appender::DBI.

   Database Initialization
       schema_exists

       returns true if the database is already (partly)	initialized.

       init_schema

       initializes the database. If the	parameter MODE is used and the value
       is DRYRUN then the function returns the SQL statements which are
       usually executed	during an initialization.

   Transaction handling
       connect

       initiates the database connection.

       disconnect

       cuts the	database connection.

       new_dbh

       get a new database handle for the object. This is called	on the
       CTX('dbi_workflow') and CTX('dbi_backend') objects when they are	forked
       (either in workflow instance forking or Net::Server forking)

       commit

       commits an active transaction.

       rollback

       aborts an active	transaction.

   SQL write operations
       get_new_serial

       This function returns a new serial number for a requested objecttype.
       Usually you only	specify	the TABLE and get a new	serial.	If you need a
       serial for a CRL	then you can simply count the CRLs to get the next
       serial. This function uses SQL sequence generators.

       Example:

	 my $serial = $dbi->get_new_serial (TABLE => "CSR");

       insert

       To insert, specify a hash reference so that the values corresponding to
       the hash	keys are inserted.  Please note	that object oriented inserts
       are no longer available.

       Example:

	 my $result = $dbi->insert (TABLE => "DATA", HASH => $data);

       update

       Specify a hash for DATA.	 Please	note that you must specify the where
       clause for an update. The background is that the	hash based interface
       supports	mass updates. If the where clause is missing then we start an
       index scan on the parameter DATA.

       Example:

	 my $result = $dbi->update (TABLE => "CSR", DATA => $data, WHERE => $index);
	 my $result = $dbi->update (TABLE => "CSR", DATA => $data);

       delete

       This function maps directly to the SQL layer. So	please check the
       documentation of	OpenXPKI::Server::DBI::SQL for a desription of the
       delete function.

   select based	functionality
       We have several functions which use the select function but hide	some
       complexity from the user.

       select

       implements an access method to the SQL select operation.	Please look at
       OpenXPKI::Server::DBI::SQL to get an overview about the available query
       options.

       get

       returns the result of a select. The important thing is that the SQL
       query only returns one row of the table.	If the query uses a unique
       index then there	can be only one	result otherwise only the first	result
       is returned. This means that the	function has the exact same behaviour
       like first. It is only a	psychological aspect that get usually includes
       a parameter for the SERIAL and first usually does not include a
       parameter with the serial.

       first

       returns the first result	of a select. The important thing is that the
       SQL query only returns one row of the table.

       last

       returns the last	result of a select. The	important thing	is that	the
       SQL query only returns one row of the table.

       next

       returns the next	result of a select. The	important thing	is that	the
       SQL query only returns one row of the table.

       prev

       returns the prev	result of a select. The	important thing	is that	the
       SQL query only returns one row of the table.

See also
       OpenXPKI::Server::DBI::Object, OpenXPKI::Server::DBI::Hash,
       OpenXPKI::Server::DBI::DBH and OpenXPKI::Server::DBI::Schema

perl v5.24.1			  2017-07-03	      OpenXPKI::Server::DBI(3)

Name | Design | Functions | See also

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=OpenXPKI::Server::DBI&sektion=3&manpath=FreeBSD+12.1-RELEASE+and+Ports>

home | help