Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test functions

get_research_requests()

Description

Retrieves research requests from the database, optionally filtering by a search term
and sorting the results by a specified field.

Parameters

ColumnTypeDefaultDescription
$find string "" Optional search term to filter research requests by name, description, contact, or reference number.
$order_by string "name" The field to sort the results by. Valid options are 'ref', 'name', 'created', 'status', or 'assigned_to'.
$sort string "ASC" The sort direction, either 'ASC' or 'DESC'. Defaults to 'ASC'.

Return

array An array of research requests that match the search criteria.

Location

include/research_functions.php lines 111 to 130

Definition

 
function get_research_requests($find="",$order_by="name",$sort="ASC")
    {
    
$searchsql="";
    
$use_order_by "";
    
$use_sort validate_sort_value($sort) ? $sort 'ASC';
    
$parameters=array();
    if (
$find!="") {
        
$searchsql="WHERE name like ? or description like ? or contact like ? or ref=?"
        
$parameters=array("s","%{$find}%""s","%{$find}%""s","%{$find}%""i",(int)$find);
    }
    if (
in_array($order_by, array("ref","name","created","status","assigned_to","collection")))
        {
        
$use_order_by $order_by;      
        }

    return 
ps_query("select " columns_in("research_request","r") . ",(select username from user u where u.ref=r.user) username, 
        (select username from user u where u.ref=r.assigned_to) assigned_username from research_request r 
        
$searchsql 
        order by 
$use_order_by $use_sort"$parameters);
    }

This article was last updated 4th December 2024 08:35 Europe/London time based on the source file dated 8th November 2024 12:05 Europe/London time.