/**
	 * Send a query to the database and return the result.
	 * @param string $Sql The sql to execute.
	 * @return bool Whethor or not the query succeeded.
	 */
	public function Query($Sql) {
		if($this->CaptureOnly) {
			if(!property_exists($this->Database, 'CapturedSql'))
				$this->Database->CapturedSql = array();
			$this->Database->CapturedSql[] = $Sql;
			return TRUE;
		} else {
			$Result = $this->Database->Query($Sql);
			return $Result;
		}
	}
 public function Query($Sql, $InputParameters = NULL, $Options = [])
 {
     // log if we want to
     if (\Config::get('forum::package.trace-include-queries', false)) {
         Trace(['sql' => $Sql, 'params' => $InputParameters, 'options' => $Options]);
     }
     // defer
     $rc = parent::Query($Sql, $InputParameters, $Options);
     // exception?
     return $rc;
 }
 /**
  * @todo Put the query debugging logic into the debug plugin.
  * 1. Create a subclass of this object where Query() does the debugging stuff.
  * 2. Install that class to Gdn to override the database.
  */
 public function Query($Sql, $InputParameters = NULL)
 {
     $Trace = debug_backtrace();
     $Method = '';
     foreach ($Trace as $Info) {
         $Class = ArrayValue('class', $Info, '');
         if ($Class === '' || strlen($Class) > 5 && substr_compare($Class, 'Model', -5, 5, FALSE) == 0) {
             $Type = ArrayValue('type', $Info, '');
             $Method = $Class . $Type . $Info['function'] . '(' . self::FormatArgs($Info['args']) . ')';
         }
     }
     // Save the query for debugging
     // echo '<br />adding to queries: '.$Sql;
     $this->_Queries[] = array('Sql' => $Sql, 'Parameters' => $InputParameters, 'Method' => $Method);
     // Start the Query Timer
     $TimeStart = list($sm, $ss) = explode(' ', microtime());
     $Result = parent::Query($Sql, $InputParameters);
     // Aggregate the query times
     $TimeEnd = list($em, $es) = explode(' ', microtime());
     $this->_ExecutionTime += $em + $es - ($sm + $ss);
     $this->_QueryTimes[] = $em + $es - ($sm + $ss);
     return $Result;
 }
 public function Query($Sql, $InputParameters = NULL, $Options = array())
 {
     $Trace = debug_backtrace();
     $Method = '';
     foreach ($Trace as $Info) {
         $Class = GetValue('class', $Info, '');
         if ($Class === '' || StringEndsWith($Class, 'Model', TRUE) || StringEndsWith($Class, 'Plugin', TRUE)) {
             $Type = ArrayValue('type', $Info, '');
             $Method = $Class . $Type . $Info['function'] . '(' . self::FormatArgs($Info['args']) . ')';
             break;
         }
     }
     // Save the query for debugging
     // echo '<br />adding to queries: '.$Sql;
     $Query = array('Sql' => $Sql, 'Parameters' => $InputParameters, 'Method' => $Method);
     $SaveQuery = TRUE;
     if (isset($Options['Cache'])) {
         $CacheKeys = (array) $Options['Cache'];
         $Cache = array();
         $AllSet = TRUE;
         foreach ($CacheKeys as $CacheKey) {
             $Value = Gdn::Cache()->Get($CacheKey);
             $CacheValue = $Value !== Gdn_Cache::CACHEOP_FAILURE;
             $AllSet &= $CacheValue;
             $Cache[$CacheKey] = $CacheValue;
         }
         $SaveQuery = !$AllSet;
         $Query['Cache'] = $Cache;
     }
     // Start the Query Timer
     $TimeStart = Now();
     $Result = parent::Query($Sql, $InputParameters, $Options);
     // Aggregate the query times
     $TimeEnd = Now();
     $this->_ExecutionTime += $TimeEnd - $TimeStart;
     if ($SaveQuery && !StringBeginsWith($Sql, 'set names')) {
         $Query['Time'] = $TimeEnd - $TimeStart;
         $this->_Queries[] = $Query;
     }
     return $Result;
 }