PMA\libraries\DatabaseInterface::tryQuery PHP Méthode

tryQuery() public méthode

runs a query and returns the result
public tryQuery ( string $query, object $link = null, integer $options, boolean $cache_affected_rows = true ) : mixed
$query string query to run
$link object mysql link resource
$options integer query options
$cache_affected_rows boolean whether to cache affected row
Résultat mixed
    public function tryQuery($query, $link = null, $options = 0, $cache_affected_rows = true)
    {
        $debug = $GLOBALS['cfg']['DBG']['sql'];
        $link = $this->getLink($link);
        if ($link === false) {
            return false;
        }
        if ($debug) {
            $time = microtime(true);
        }
        $result = $this->_extension->realQuery($query, $link, $options);
        if ($cache_affected_rows) {
            $GLOBALS['cached_affected_rows'] = $this->affectedRows($link, false);
        }
        if ($debug) {
            $time = microtime(true) - $time;
            $this->_dbgQuery($query, $link, $result, $time);
            if ($GLOBALS['cfg']['DBG']['sqllog']) {
                openlog('phpMyAdmin', LOG_NDELAY | LOG_PID, LOG_USER);
                syslog(LOG_INFO, 'SQL[' . basename($_SERVER['SCRIPT_NAME']) . ']: ' . sprintf('%0.3f', $time) . ' > ' . $query);
            }
        }
        if (!empty($result) && Tracker::isActive()) {
            Tracker::handleQuery($query);
        }
        return $result;
    }

Usage Example

 /**
  * Handle compatibility options
  *
  * @param PMA\libraries\DatabaseInterface $dbi     Database interface
  * @param array                           $request Request array
  *
  * @return void
  */
 private function _setSQLMode($dbi, $request)
 {
     $sql_modes = array();
     if (isset($request['sql_compatibility']) && 'NONE' != $request['sql_compatibility']) {
         $sql_modes[] = $request['sql_compatibility'];
     }
     if (isset($request['sql_no_auto_value_on_zero'])) {
         $sql_modes[] = 'NO_AUTO_VALUE_ON_ZERO';
     }
     if (count($sql_modes) > 0) {
         $dbi->tryQuery('SET SQL_MODE="' . implode(',', $sql_modes) . '"');
     }
 }
All Usage Examples Of PMA\libraries\DatabaseInterface::tryQuery