Jump to content
Wiki Home
EPrints Home
Bazaar
Files
Main menu
Main menu
move to sidebar
hide
Navigation
Front Page
EPrints 3 Manual
EPrints Training Course
EPrints Glossary
Installing EPrints
How-to Configure EPrints
EPrints 3.2+ API
EPrints 3 Reference
EPrints Plugins
Wiki
All categories
Recent changes
Main Page
Help
EPrints Documentation
Search
Search
Appearance
Log in
Request account
Personal tools
Log in
Request account
Pages for logged out editors
learn more
Contributions
Talk
Editing
API:EPrints/Database
(section)
Page
Discussion
British English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==METHODS== <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=head_database --> ===Database=== <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_new --> ====new==== $db = EPrints::Database->new( $repo, [ %opts ] ) Create a connection to the database. Options: db_connect - Boolean. Also connect to the database (default: true). <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_create --> ====create==== $db = $db->create( $username, $password ) Create and connect to a new database using user account <tt>$username</tt> and <tt>$password</tt>. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_build_connection_string --> ====build_connection_string==== $dbstr = EPrints::Database::build_connection_string( %params ) Build the string to use to connect to the database via {{API:PodLink|file=DBI|package_name=DBI|section=|text=DBI}}. Parameters: dbname - Database name (REQUIRED). dbdriver - Database driver (e.g. mysql, Oracle, pgsql, default: mysql). dbhost - Database host. Assumes localhost if unset. dbport - Port to connect to database host. Assumes default for driver if unset. dbsock - Socket file to connect to database through. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_connect --> ====connect==== $db->connect() Connects to the database. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_disconnect --> ====disconnect==== $db->disconnect() Disconnects from the EPrints database. Should always be done before any script exits. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_set_debug --> ====set_debug==== $db->set_debug( $boolean ) Set the SQL debug mode to <tt>true</tt> or <tt>false</tt>. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_set_version --> ====set_version==== $db->set_version( $versionid ); Set the version id table in the SQL database to the given <tt>versionid</tt> (used by the upgrade script). <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_get_version --> ====get_version==== $version = $db->get_version Returns the current database schema version. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_is_latest_version --> ====is_latest_version==== $boolean = $db->is_latest_version Return <tt>true</tt> if the SQL tables are in the correct configuration for this edition of eprints. Otherwise, <tt>false</tt>. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_get_server_version --> ====get_server_version==== $version = $db->get_server_version Return the database server version. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_get_default_charset --> ====get_default_charset==== $charset = $db->get_default_charset Return the character set to use. Returns <tt>undef</tt> if character sets are unsupported. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_get_default_collation --> ====get_default_collation==== $collation = $db->get_default_collation( $lang ) Return the collation to use for language <tt>$lang</tt>. Returns <tt>undef</tt> if collation is unsupported. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_get_driver_name --> ====get_driver_name==== $driver = $db->get_driver_name Return the database driver name. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_error --> ====error==== $errstr = $db->error() Return a string describing the last SQL error. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_retry_error --> ====retry_error==== $boolean = $db->retry_error() Returns a boolean for whether the database error is a retry error. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_duplicate_error --> ====duplicate_error==== $boolean = $db->duplicate_error() Returns a boolean for whether the database error is a duplicate error. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_begin --> ====begin==== $db->begin() Begin a transaction. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_commit --> ====commit==== $db->commit() Commit the previously begun transaction. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_rollback --> ====rollback==== $db->rollback() Rollback the partially completed transaction. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_type_info --> ====type_info==== $type_info = $db->type_info( $data_type ) See {{API:PodLink|file=DBI|package_name=DBI|section=type_info|text=DBI/type_info}}. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_get_column_type --> ====get_column_type==== $real_type = $db->get_column_type( $name, $data_type, $not_null, [ $length, $scale, %opts ] ) Returns a SQL column definition for <tt>$name</tt> of type <tt>$type</tt>, usually something like: $name $type($length,$scale) [ NOT NULL ] If <tt>$not_null</tt> is <tt>true</tt> column will be set to <tt>NOT NULL</tt>. <tt>$length</tt> and <tt>$scale</tt> control the maximum lengths of character or decimal types (see below). Other options available to refine the column definition: langid - character set/collation to use sorted - whether this column will be used to order by '''langid''' is mapped to real database values by the "dblanguages" configuration option. The database may not be able to order the request column type in which case, if <tt>sorted</tt> is true, the database may use a substitute column type. <tt>$data_type</tt> is the SQL type. The types are constants defined by this module, to import them use: use EPrints::Database qw( :sql_types ); Supported types (n = requires <tt>$length</tt> argument): Character data: <tt>SQL_VARCHAR(n)</tt>, <tt>SQL_LONGVARCHAR</tt>, <tt>SQL_CLOB</tt>. Binary data: <tt>SQL_VARBINARY(n)</tt>, <tt>SQL_LONGVARBINARY</tt>. Integer data: <tt>SQL_TINYINT</tt>, <tt>SQL_SMALLINT</tt>, <tt>SQL_INTEGER</tt>, <tt>SQL_BIGINT</tt>. Floating-point data: <tt>SQL_REAL</tt>, <tt>SQL_DOUBLE</tt>. Time data: <tt>SQL_DATE</tt>, <tt>SQL_TIME</tt>. The actual column types used will be database-specific. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=head_basic_sql_operations --> ===Basic SQL Operations=== <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_do --> ====do==== $success = $db->do( $sql ) Execute the given <tt>$sql</tt>. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_prepare --> ====prepare==== $sth = $db->prepare( $sql ) Prepare the given <tt>$sql</tt> and return a handle on it. Use the <tt>execute</tt> method on the returned {{API:PodLink|file=DBI|package_name=DBI|section=|text=DBI}} handle to execute the SQL: my $sth = $db->prepare_select( "SELECT 'Hello, World'" ); $sth->execute; <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_prepare_select --> ====prepare_select==== $sth = $db->prepare_select( $sql, [ %options ] ) Prepare a <tt>SELECT</tt> statement <tt>$sql</tt> and return a handle to it. After preparing a statement use <tt>execute()</tt> to execute it. Returns a {{API:PodLink|file=DBI|package_name=DBI|section=|text=DBI}} statement handle. The <tt>LIMIT</tt> SQL keyword is not universally supported, to specify this use the <tt>limit</tt> option. Options: limit - limit the number of rows returned offset - return '''limit''' number of rows after offset <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_execute --> ====execute==== $success = $db->execute( $sth, $sql ) Execute the SQL prepared earlier in the <tt>$sth</tt>. <tt>$sql</tt> is only required for debugging purposes. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_update --> ====update==== $success = $db->update( $dataset, $data, $changed ) Updates a <tt>EPrints::DataObj</tt> from <tt>$dataset</tt> with the given <tt>$data</tt>. The primary key field (e.g. <tt>eprintid</tt>) value must be included. Updates the <tt>ordervalues</tt> if the <tt>$dataset</tt> is {{API:PodLink|file=EPrints/DataSet#ordered|package_name=EPrints::DataSet#ordered|section=|text=ordered}}. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item__update --> ====_update==== $rows = $db->_update( $tablename, $keycols, $keyvals, $columns, @values ) Updates <tt>$columns</tt> in <tt>$tablename</tt> with <tt>@values</tt> where <tt>$keycols</tt> equals <tt>$keyvals</tt> and returns the number of rows affected. N.B. If no rows are affected, the result is still <tt>true</tt>, see {{API:PodLink|file=DBI|package_name=DBI|section=|text=DBI}}'s <tt>execute()</tt> method. This is an internal method. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_insert --> ====insert==== $success = $db->insert( $table, $columns, @values ) Inserts <tt>@values</tt> into the table <tt>$table</tt>. If <tt>$columns</tt> is defined it will be used as a list of columns to insert into. <tt>@values</tt> is a list of arrays containing values to insert. These will be quoted before insertion. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_insert_quoted --> ====insert_quoted==== $success = $db->insert_quoted( $table, $columns, @qvalues ) Inserts values into the table <tt>$table</tt>. If <tt>$columns</tt> is defined it will be used as a list of columns to insert into. <tt>@qvalues</tt> is a list of arrays containing values to insert. These will NOT be quoted before insertion - care must be exercised! <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_delete_from --> ====delete_from==== $success = $db->delete_from( $table, $columns, @values ) Perform a SQL <tt>DELETE FROM</tt> <tt>$table</tt> using <tt>$columns</tt> to build a where clause. <tt>@values</tt> is a list of array references of values in the same order as <tt>$columns</tt>. If you want to clear a table completely use <tt>clear_table()</tt>. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_count_table --> ====count_table==== $n = $db->count_table( $tablename ) Return the number of rows in the specified SQL table with <tt>$tablename</tt>. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_clear_table --> ====clear_table==== $db->clear_table( $tablename ) Clears all records from the given table with <tt>$tablename</tt>. Use with caution! <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=head_quoting --> ===Quoting=== <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_prep_int --> ====prep_int==== $mungedvalue = EPrints::Database::prep_int( $value ) Escape numerical <tt>$value</tt> for an SQL statement. <tt>undef</tt> becomes <tt>NULL</tt>. Anything else becomes a number (zero if needed). <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_prep_value --> ====prep_value==== $mungedvalue = EPrints::Database::prep_value( $value ) Escape <tt>$value</tt> for an SQL statement. Modify value such that <tt>"</tt> becomes <tt>\"</tt> and <tt>\</tt> becomes <tt>\\</tt> and <tt>'</tt> becomes <tt>\'</tt>. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_prep_like_value --> ====prep_like_value==== $mungedvalue = EPrints::Database::prep_like_value( $value ) Escape <tt>$value</tt> for an SQL <tt>LIKE</tt> clause. In addition to <tt>'</tt> <tt>"</tt> and <tt>\</tt> also escapes <tt>%</tt> and <tt>_</tt>. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_quote_value --> ====quote_value==== $str = $db->quote_value( $value ) Return a quoted version of <tt>$value</tt>. To quote a <tt>LIKE</tt> value you should use: $db->quote_value( EPrints::Database::prep_like_value( $foo ) . '%' ); <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_quote_int --> ====quote_int==== $str = $db->quote_int( $value ) Return a quoted integer for <tt>$value</tt>. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_quote_binary --> ====quote_binary==== $str = $db->quote_binary( $bytes ) Some databases (Oracle/PostgreSQL) require transforms of binary data to work correctly. This method should be called on data <tt>$bytes</tt> containing null bytes or back-slashes before being passed on [[API:EPrints/Database#quote_value|quote_value]]. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_quote_ordervalue --> ====quote_ordervalue==== $str = $db->quote_ordervalue( $field, $value ) Some databases (Oracle) can't order by <tt>CLOB</tt>s so need special treatment when creating the ordervalues tables. This method allows any fixing-up required for string data <tt>$value</tt> for <tt>$field</tt> before it's inserted. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_quote_identifier --> ====quote_identifier==== $str = $db->quote_identifier( @parts ) Quote a database identifier (e.g. table names). Multiple <tt>@parts</tt> will be joined by dots (<tt>.</tt>). <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_prepare_regexp --> ====prepare_regexp==== $sql = $db->prepare_regexp( $col, $value ) The syntax used for regular expressions varies across databases. This method takes two quoted string and returns a SQL expression that will apply the quoted regexp <tt>$value</tt> to the quoted column <tt>$col</tt>. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_sql_as --> ====sql_as==== $sql = $db->sql_AS() Returns the syntactic glue to use when aliasing. SQL 92 databases will happily use <tt>AS</tt> but some databases (Oracle) will not accept it. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_sql_like --> ====sql_like==== $sql = $db->sql_LIKE() Returns the syntactic glue to use when making a case-insensitive <tt>LIKE</tt>. PostgreSQL requires <tt>ILIKE</tt> while everything else uses <tt>LIKE</tt> and the column collation. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=head_counters --> ===Counters=== <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_counter_current --> ====counter_current==== $n = $db->counter_current( $counter ) Return the value of the previous counter_next on <tt>$counter</tt>. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_counter_next --> ====counter_next==== $n = $db->counter_next( $counter ) Return the next unused value for the named <tt>$counter</tt>. Returns <tt>undef</tt> if the <tt>$counter</tt> doesn't exist. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_counter_minimum --> ====counter_minimum==== $db->counter_minimum( $counter, $value ) Ensure that the <tt>$counter</tt> is set no lower than <tt>$value</tt>. This is used when importing eprints which may not be in scrict sequence. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_counter_reset --> ====counter_reset==== $db->counter_reset( $counter ) Reset the <tt>$counter</tt>. Use with caution. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_next_doc_pos --> ====next_doc_pos==== $n = $db->next_doc_pos( $eprintid ) Return the next unused document position for the given <tt>$eprintid</tt>. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=head_dataset_data --> ===Dataset Data=== <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_exists --> ====exists==== $boolean = $db->exists( $dataset, $id ) Return <tt>true</tt> if there exists an [[API:EPrints/DataObj|EPrints::DataObj]] from the <tt>$dataset</tt> with its primary key set to <tt>$id</tt>. Otherwise, return <tt>false</tt>. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_add_record --> ====add_record==== $success = $db->add_record( $dataset, $data ) Add the given <tt>$data</tt> as a new record in the given <tt>$dataset</tt>. <tt>$data</tt> is a reference to a hash containing values structured for a record in the that <tt>$dataset</tt>. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_remove --> ====remove==== $success = $db->remove( $dataset, $id ) Attempts to remove the [[API:EPrints/DataObj|EPrints::DataObj]] with the primary key <tt>$id</tt> from the specified <tt>$dataset</tt>. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=head_searching_caching_and_object_retrieval --> ===Searching, caching and object retrieval=== <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_cache_exp --> ====cache_exp==== $searchexp = $db->cache_exp( $cacheid ) Return the serialised search of a the cached search with <tt>$cacheid</tt>. Return <tt>undef</tt> if the <tt>$cacheid</tt> is invalid or expired. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_cache --> ====cache==== $cacheid = $db->cache( $searchexp, $dataset, $srctable, [$order], [$list] ) Create a cache of the specified search expression from the SQL table <tt>$srctable</tt>. If <tt>$order</tt> is set then the cache is ordered by the specified fields. For example <tt>-year/title</tt> orders by year (descending). Records with the same year are ordered by title. If <tt>$srctable</tt> is set to <tt>LIST</tt> then order is ignored and the list of IDs is taken from the array reference <tt>$list</tt>. If <tt>$srctable</tt> is set to <tt>ALL</tt> every matching record from $dataset is added to the cache, optionally ordered by <tt>$order</tt>. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_cache_table --> ====cache_table==== $tablename = $db->cache_table( $id ) Return the name of the SQL table used to store the cache with <tt>$id</tt>. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_cache_userid --> ====cache_userid==== $userid = $db->cache_userid( $id ) Returns the <tt>userid</tt> associated with the cache with <tt>$id</tt> if that cache exists. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_get_cachemap --> ====get_cachemap==== $cachemap = $db->get_cachemap( $id ) Return the cachemap with $<id>. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_search --> ====search==== $ids = $db->search( $keyfield, $tables, $conditions, [ $main_table_alias ] ) Return a reference to an array of <tt>$keyfield</tt> IDs - the results of the search specified by <tt>$conditions</tt> across the tables specified in the <tt>$tables</tt> hash where keys are tables aliases and values are table names. If no <tt>$main_table_alias</tt> is specified then <tt>M</tt> is assumed. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_drop_cache --> ====drop_cache==== $db->drop_cache( $id ) Remove the cached search with the given <tt>$id</tt>. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_from_cache --> ====from_cache==== $items = $db->from_cache( $dataset, $cacheid, [ $offset, $count, $justids ] ) Return a reference to an array containing all the items from the given <tt>$dataset</tt> that have IDs in the cache specified by <tt>$cacheid</tt>. The cache may be specified either by ID or serialised search expression. <tt>$offset</tt> is an offset from the start of the cache and <tt>$count</tt> is the number of records to return. If <tt>$justids</tt> is <tt>true</tt> then it returns just a reference to an array of the record IDs and not the objects themselves. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_drop_orphan_cache_tables --> ====drop_orphan_cache_tables==== $c = $db->drop_orphan_cache_tables Drop tables called <tt>cacheXXX</tt> where <tt>XXX</tt> is an integer. Returns the number of cache tables dropped. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_get_single --> ====get_single==== $obj = $db->get_single( $dataset, $id ) Return a single <EPrints::DataObj> from the given <tt>$dataset</tt> with primary key set to <tt>$id</tt>. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_get_all --> ====get_all==== $items = $db->get_all( $dataset ) Returns a reference to an array with all the <EPrints::DataObj>s from the given <tt>$dataset</tt>. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_get_cache_ids --> ====get_cache_ids==== @ids = $db->get_cache_ids( $dataset, $cachemap, $offset, $count ) Returns a list of <tt>$count</tt> IDs from <tt>$cache_id</tt> starting at <tt>$offset</tt> and in the order in the <tt>$cachemap</tt>. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_get_dataobjs --> ====get_dataobjs==== @dataobjs = $db->get_dataobjs( $dataset, [ $id, $id, ... ] ) Retrieves the records in <tt>$dataset</tt> with the given <tt>$id</tt>(s). If an <tt>$id</tt> doesn't exist in the database it will be ignored. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_get_values --> ====get_values==== $values = $db->get_values( $field, $dataset ) Return a reference to an array of all the distinct values of the [[API:EPrints/MetaField|EPrints::MetaField]] <tt>$field</tt> for the <tt>$dataset</tt> specified. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_sort_values --> ====sort_values==== $values = $db->sort_values( $field, $values, [ $langid ] ) Sorts and returns the list of <tt>$values</tt> using the database. <tt>$field</tt> is used to get the order value for each value. <tt>$langid</tt> (or $session->get_langid if unset) is used to determine the database collation to use when sorting the resulting order values. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_get_ids_by_field_values --> ====get_ids_by_field_values==== $ids = $db->get_ids_by_field_values( $field, $dataset, [ %opts ] ) Return a reference to a hash table where the keys are specified <tt>$datasets</tt>'s <tt>$field</tt> value IDs and the values are references to arrays of IDs. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_dequeue_events --> ====dequeue_events==== @events = $db->dequeue_events( $n ) Attempt to dequeue upto <tt>$n</tt> events. May return between <tt>0</tt> and <tt>$n</tt> events depending on parallel processes and how many events are remaining in the queue. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_ci_lookup --> ====ci_lookup==== $value = $db->ci_lookup( $field, $value ) This is a hacky method to support case-insensitive lookup for usernames, emails, etc. It returns the actual case-sensitive version of <tt>$value</tt> if there is a case-insensitive match for the <tt>$field</tt>. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=head_password_validation_and_secret_fields --> ===Password Validation and Secret Fields=== <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_valid_login --> ====valid_login==== $db->valid_login( $username, $password ) Returns whether the clear-text <tt>$password</tt> matches the stored crypted password for the <tt>$username</tt>. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_secret_matches --> ====secret_matches==== $db->secret_matches( $dataobj, $fieldname, $token [, $callback ] ) Returns whether the clear-text <tt>$token</tt> matches the stored crypted field with <tt>$fieldname</tt> for the <tt>$dataobj</tt> according to the <tt>$callback</tt> function. If not set, <tt>$callback</tt> defaults to [[API:EPrints/Utils#crypt_equals|EPrints::Utils#crypt_equals]]. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_is_secret_set --> ====is_secret_set==== $boolean = $db->is_secret_set( $dataobj, $fieldname ) Returns a boolean for whether the secret <tt>$fieldname</tt> for <tt>$dataobj</tt> has a value set. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=head_database_schema_manipulation --> ===Database Schema Manipulation=== <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_has_sequence --> ====has_sequence==== $boolean = $db->has_sequence( $name ) Returns <tt>true</tt> if a sequence of the given <tt>$name</tt> exists in the database. Otherwise, returns <tt>false</tt>. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_create_sequence --> ====create_sequence==== $success = $db->create_sequence( $name ) Creates a new sequence object with <tt>$name</tt> and initialises to zero. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_drop_sequence --> ====drop_sequence==== $success = $db->drop_sequence( $name ) Deletes a sequence object with <tt>$name</tt>. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_has_column --> ====has_column==== $boolean = $db->has_column( $table, $column ) Return <tt>true</tt> if the named <tt>$table</tt> has the named <tt>$column</tt> in the database. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_drop_column --> ====drop_column==== $success = $db->drop_column( $table, $column ) Drops the named <tt>$column</tt> from the named <tt>$table</tt>. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_get_primary_key --> ====get_primary_key==== @columns = $db->get_primary_key( $tablename ) Returns a list of column names that comprise the primary key for the <tt>$tablename</tt>. Returns an empty list if no primary key exists. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_index_name --> ====index_name==== $name = $db->index_name( $table, @cols ) Returns the name of the first index that starts with named columns <tt>@cols</tt> in the named <tt>$table</tt>. Returns <tt>undef</tt> if no index exists. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_get_index_ids --> ====get_index_ids==== $ids = $db->get_index_ids( $table, $condition ) Return a reference to an array of the distinct primary keys from the named SQL <tt>$table</tt> which match the specified <tt>$condition</tt>. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_create_index --> ====create_index==== $success = $db->create_index( $table, @columns ) Creates an index over <tt>@columns</tt> for named <tt>$table</tt>. Returns <tt>true</tt> on success, <tt>false</tt> otherwise. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_create_unique_index --> ====create_unique_index==== $success = $db->create_unique_index( $tablename, @columns ) Creates a unique index over <tt>@columns</tt> for named <tt>$table</tt>. Returns <tt>true</tt> on success, <tt>false</tt> otherwise. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_create_foreign_key --> ====create_foreign_key==== $ok = $db->create_foreign_key( $main_table, $table, $key_field ) Create a foreign key relationship between named <tt>$main_table</tt> and named <tt>$table</tt> using <tt>$key_field</tt>. This will cause records in <tt>$table</tt> to be deleted if the equivalent record is deleted from <tt>$main_table</tt>. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_get_tables --> ====get_tables==== @tables = $db->get_tables( [ $dbname ] ) Returns a list of all the tables in the database. <tt>$dbname</tt> specifies a particular database name of current connection has access to more than one database. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_has_table --> ====has_table==== $boolean = $db->has_table( $tablename ) Returns boolean dependent on whether a table of the <tt>$tablename</tt> exists in the database. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_create_table --> ====create_table==== $success = $db->create_table( $tablename, $setkey, @fields ); Creates a new table with <tt>$tablename</tt> based on <tt>@fields</tt>. The first <tt>$setkey</tt> number of fields are used for its primary key. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_drop_table --> ====drop_table==== $db->drop_table( @tables ) Delete the named <tt>@tables</tt>. Use with caution! <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_rename_table --> ====rename_table==== $db->rename_table( $table_from, $table_to ) Renames the table named <tt>$table_from</tt> to <tt>$table_to</tt>. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_swap_table --> ====swap_table==== $db->swap_table( $table_a, $table_b ) Renames table named <tt>$table_a</tt> to <tt>$table_b</tt> and vice-versa. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=head_eprints_schema_manipulation --> ===EPrints Schema Manipulation=== <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_create_archive_tables --> ====create_archive_tables==== $success = $db->create_archive_tables() Create all the SQL tables for all datasets. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_drop_archive_tables --> ====drop_archive_tables==== $db->drop_archive_tables() Destroy all tables used by EPrints in the database. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_create_version_table --> ====create_version_table==== $db->create_version_table Make the version table (and set the only value to be the current version of EPrints). <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_drop_version_table --> ====drop_version_table==== $db->drop_version_table Drop the version table. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_has_dataset --> ====has_dataset==== $db->has_dataset( $dataset ) Returns <tt>true</tt> if <tt>$dataset</tt> exists in the database and has all expected tables including ordervalues and index tables. This does not check that all fields are configured - see </has_field>. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_has_dataset_index_tables --> ====has_dataset_index_tables==== $db->has_dataset_index_tables( $dataset ) Returns <tt>true</tt> if index tables for <tt>$dataset</tt> exists of if this is not indexable. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_create_dataset_tables --> ====create_dataset_tables==== $success = $db->create_dataset_tables( $dataset ) Creates all the SQL tables for the specified <tt>$dataset</tt>. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_drop_dataset_tables --> ====drop_dataset_tables==== $db->drop_dataset_tables( $dataset ) Drops all the SQL tables for the specified <tt>$dataset</tt>. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_create_dataset_index_tables --> ====create_dataset_index_tables==== $success = $db->create_dataset_index_tables( $dataset ) Creates all the index tables for the specified <tt>$dataset</tt>. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_create_dataset_ordervalues_tables --> ====create_dataset_ordervalues_tables==== $success = $db->create_dataset_ordervalues_tables( $dataset ) Creates all the ordervalues tables for the specified <tt>$dataset</tt>. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_has_field --> ====has_field==== $db->has_field( $dataset, $field ) Returns <tt>true</tt> if <tt>$field</tt> is in the database for <tt>$dataset</tt>. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_add_field --> ====add_field==== $db->add_field( $dataset, $field, [ $force ] ) Add <tt>$field</tt> to <tt>$dataset</tt>'s tables. If <tt>$force</tt> is <tt>true</tt> modify/replace an existing column. Use with care! <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_remove_field --> ====remove_field==== $db->remove_field( $dataset, $field ) Remove <tt>$field</tt> from <tt>$dataset</tt>'s tables. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_rename_field --> ====rename_field==== $ok = $db->rename_field( $dataset, $field, $old_name ) Rename the <tt>$field</tt> in the <tt>$dataset</tt> from its <tt>$old_name</tt>. Returns <tt>true</tt> if the <tt>$field</tt> is successfully renamed. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_create_counters --> ====create_counters==== $success = $db->create_counters Create the counters used to store the highest current ID of eprints, users, etc. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_has_counter --> ====has_counter==== $success = $db->has_counter( $counter ) Returns <tt>true</tt> if <tt>$counter</tt> exists. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_create_counter --> ====create_counter==== $success = $db->create_counter( $name ) Create and initialise to zero a new counter with <tt>$name</tt>. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_remove_counters --> ====remove_counters==== $success = $db->remove_counters Destroy all counters. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_drop_counter --> ====drop_counter==== $success = $db->drop_counter( $name ) Destroy the counter named <tt>$name</tt>. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=head_user_messages --> ===User Messages=== <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_save_user_message --> ====save_user_message==== $message = $db->save_user_message( $userid, $m_type, $dom_m_data ) Save user message provided in XML DOM object <tt>$dom_m_data</tt> as a sanitized string in a [[API:EPrints/DataObj/Message|EPrints::DataObj::Message]] using <tt>$m_type</tt> to define the message type and <tt>$userid</tt> for the ID of the user whose message it is. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_get_user_messages --> ====get_user_messages==== @messages = $db->get_user_messages( $userid, %opts ) Get the messages for a user with ID <tt>$userid</tt> and clear messages if <tt>$opt{clear}</tt> is set. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=item_clear_user_messages --> ====clear_user_messages==== $db->clear_user_messages( $userid ) Clear all messages for user with ID <tt>$userid</tt>. <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> <span style='display:none'>User Comments</span> <!-- Edit below this comment --> <!-- Pod2Wiki= --> </div> <!-- Pod2Wiki=head_see_also -->
Summary:
Please note that all contributions to EPrints Documentation may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
EPrints Documentation:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)