Search::getDatas PHP Method

getDatas() static public method

Get datas based on search parameters
static public getDatas ( $itemtype, $params, array $forcedisplay = [] ) : data
$itemtype item type to manage
$params search params passed to prepareDatasForSearch function
$forcedisplay array array of columns to display (default empty = empty use display pref and search criterias)
return data array
    static function getDatas($itemtype, $params, array $forcedisplay = array())
    {
        $data = self::prepareDatasForSearch($itemtype, $params, $forcedisplay);
        self::constructSQL($data);
        self::constructDatas($data);
        return $data;
    }

Usage Example

Example #1
0
 private function doSearch($itemtype, $params, array $forcedisplay = array())
 {
     global $DEBUG_SQL;
     // check param itemtype exists (to avoid search errors)
     $this->assertTrue(is_subclass_of($itemtype, "CommonDBTM"));
     // login to glpi if needed
     if (!isset($_SESSION['glpiname'])) {
         $this->Login();
     }
     // force session in debug mode (to store & retrieve sql errors)
     $glpi_use_mode = $_SESSION['glpi_use_mode'];
     $_SESSION['glpi_use_mode'] = Session::DEBUG_MODE;
     // don't compute last request from session
     $params['reset'] = 'reset';
     // do search
     $params = Search::manageParams($itemtype, $params);
     $data = Search::getDatas($itemtype, $params, $forcedisplay);
     // append existing errors to returned data
     $data['last_errors'] = array();
     if (isset($DEBUG_SQL['errors'])) {
         $data['last_errors'] = implode(', ', $DEBUG_SQL['errors']);
         unset($DEBUG_SQL['errors']);
     }
     // restore glpi mode to previous
     $_SESSION['glpi_use_mode'] = $glpi_use_mode;
     // do not store this search from session
     Search::resetSaveSearch();
     return $data;
 }
All Usage Examples Of Search::getDatas