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!
===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 -->
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)