function actionStandaloneTimer()
 {
     // Instantiate the timer
     $timer = new YDTimer();
     // The original data
     $timer->addMarker('Reading file');
     $file = new YDFSFile('bbcode.txt');
     $data = $file->getContents();
     $timer->addMarker('Finished reading file');
     // The converter
     $timer->addMarker('YDBBCode object');
     $conv = new YDBBCode();
     // Show the converted data
     $timer->addMarker('Conversion to BBCode');
     echo '<pre>' . htmlentities($data) . '</pre>';
     echo '<pre>' . htmlentities($conv->toHtml($data)) . '</pre>';
     echo '<p>' . $conv->toHtml($data, true, false) . '</p>';
     // Get the report
     $report = $timer->getReport();
     // Dump the contents of the report
     YDDebugUtil::dump($report, 'Timing report');
 }
 /**
  *	This function will connect to the database, execute a query and will return the result handle.
  *
  *	@param $sql	The SQL statement to execute.
  *
  *  @returns    Handle to the result of the query. In case of an error, this function triggers an error.
  *
  *	@internal
  */
 function &_connectAndExec($sql)
 {
     // Add the table prefix
     $sql = str_replace(' #_', ' ' . YDConfig::get('YD_DB_TABLEPREFIX', ''), $sql);
     // Update the language placeholders
     $languageIndex = YDConfig::get('YD_DB_LANGUAGE_INDEX', null);
     if (!is_null($languageIndex)) {
         $sql = str_replace('_@', '_' . $languageIndex, $sql);
     }
     // Connect
     $result = $this->connect();
     // Handle errors
     if (!$result && $this->_failOnError === true) {
         $error = ocierror();
         trigger_error($error['message'], YD_ERROR);
     }
     // Record the start time
     $timer = new YDTimer();
     // Create statement
     $stmt = OCIParse($this->_conn, $sql);
     // Handle errors
     if (!$stmt && $this->_failOnError === true) {
         $error = ocierror($stmt);
         trigger_error($error['message'], YD_ERROR);
     }
     // Execute
     $result = @OCIExecute($stmt);
     // Handle errors
     if ($result === false && $this->_failOnError === true) {
         $error = ocierror($stmt);
         if (!empty($error['sqltext'])) {
             $error['message'] .= ' (SQL: ' . $error['sqltext'] . ')';
         }
         echo '<b>Stacktrace:</b> <pre>' . YDDebugUtil::getStackTrace() . '</pre>';
         echo '<b>SQL Statement:</b> <pre>' . $this->formatSql($sql) . '</pre>';
         trigger_error($error['message'], YD_ERROR);
     }
     // Log the statement
     $this->_logSql($sql, $timer->getElapsed());
     // Return the result
     return $stmt;
 }
 /**
  *  This function will connect to the database, execute a query and will return the result handle.
  *
  *  @param $sql The SQL statement to execute.
  *
  *  @returns    Handle to the result of the query.
  *
  *  @internal
  */
 function &_connectAndExec($sql)
 {
     // Add the table prefix
     $sql = str_replace(' #_', ' ' . YDConfig::get('YD_DB_TABLEPREFIX', ''), $sql);
     $sql = str_replace(' `#_', ' `' . YDConfig::get('YD_DB_TABLEPREFIX', ''), $sql);
     // Connect
     $result = $this->connect();
     // Handle errors
     if (!$result && is_null($this->_conn) && $this->_failOnError === true) {
         trigger_error(mysql_error(), YD_ERROR);
     }
     if (!$result && !is_null($this->_conn) && $this->_failOnError === true) {
         trigger_error(mysql_error($this->_conn), YD_ERROR);
     }
     // Record the start time
     $timer = new YDTimer();
     // Execute the query
     $result = @mysql_query($sql, $this->_conn);
     // Handle errors
     if ($result === false && $this->_failOnError === true) {
         YDDebugUtil::error('[' . mysql_errno($this->_conn) . '] ' . mysql_error($this->_conn), $sql);
     }
     // Log the statement
     $this->_logSql($sql, $timer->getElapsed());
     // Return the result
     return $result;
 }
 /**
  *	This function will connect to the database, execute a query and will return the result handle.
  *
  *	@param $sql	The SQL statement to execute.
  *
  *	@returns	Handle to the result of the query.
  *
  *	@internal
  */
 function &_connectAndExec($sql)
 {
     // Add the table prefix
     $sql = str_replace(' #_', ' ' . YDConfig::get('YD_DB_TABLEPREFIX', ''), $sql);
     // Update the language placeholders
     $languageIndex = YDConfig::get('YD_DB_LANGUAGE_INDEX', null);
     if (!is_null($languageIndex)) {
         $sql = str_replace('_@', '_' . $languageIndex, $sql);
     }
     // Connect
     $result = $this->connect();
     // Record the start time
     $timer = new YDTimer();
     // Perform the query
     $result = $this->_conn->queryExec($sql);
     // Handle errors
     if ($result === false && $this->_failOnError === true) {
         echo '<b>Stacktrace:</b> <pre>' . YDDebugUtil::getStackTrace() . '</pre>';
         echo '<b>SQL Statement:</b> <pre>' . $this->formatSql($sql) . '</pre>';
         $msg = $this->_conn->errorInfo();
         trigger_error('<b>SQLite error message: </b>' . $msg[2], YD_ERROR);
     }
     // Log the statement
     $this->_logSql($sql, $timer->getElapsed());
     // Return the result
     return $result;
 }
 /**
  *	This function will connect to the database, execute a query and will return the result handle.
  *
  *	@param $sql	The SQL statement to execute.
  *
  *	@returns	Handle to the result of the query.
  *
  *	@internal
  */
 function &_connectAndExec($sql)
 {
     // Add the table prefix
     $sql = str_replace(' #_', ' ' . YDConfig::get('YD_DB_TABLEPREFIX', ''), $sql);
     // Update the language placeholders
     $languageIndex = YDConfig::get('YD_DB_LANGUAGE_INDEX', null);
     if (!is_null($languageIndex)) {
         $sql = str_replace('_@', '_' . $languageIndex, $sql);
     }
     // Connect to database
     $result = $this->connect();
     // Handle errors
     if (!$result && $this->_failOnError === true) {
         trigger_error($GLOBALS['YD_SQLITE_error'], YD_ERROR);
     }
     // Record the start time
     $timer = new YDTimer();
     // Execute the query
     $result = @sqlite_query($sql, $this->_conn);
     // Handle errors
     if ($result === false && $this->_failOnError === true) {
         echo '<b>Stacktrace:</b> <pre>' . YDDebugUtil::getStackTrace() . '</pre>';
         echo '<b>SQL Statement:</b> <pre>' . $this->formatSql($sql) . '</pre>';
         trigger_error(sqlite_error_string(sqlite_last_error($this->_conn)), YD_ERROR);
     }
     // Log the statement
     $this->_logSql($sql, $timer->getElapsed());
     // Return the result
     return $result;
 }
 /**
  *	This function will connect to the database, execute a query and will return the result handle.
  *
  *	@param $sql	The SQL statement to execute.
  *
  *	@returns	Handle to the result of the query.
  *
  *	@internal
  */
 function &_connectAndExec($sql)
 {
     // Add the table prefix
     $sql = str_replace(' #_', ' ' . YDConfig::get('YD_DB_TABLEPREFIX', ''), $sql);
     // Connect
     $result = $this->connect();
     // Handle errors
     if (!$result && $this->_failOnError === true) {
         trigger_error(pg_last_error(), YD_ERROR);
     }
     // Record the start time
     $timer = new YDTimer();
     // Perform the query
     $result = @pg_query($this->_conn, $sql);
     // Handle errors
     if ($result === false && $this->_failOnError === true) {
         echo '<b>Stacktrace:</b> <pre>' . YDDebugUtil::getStackTrace() . '</pre>';
         echo '<b>SQL Statement:</b> <pre>' . $this->formatSql($sql) . '</pre>';
         trigger_error(pg_last_error($this->conn), YD_ERROR);
     }
     // Log the statement
     $this->_logSql($sql, $timer->getElapsed());
     // Return the result
     return $result;
 }
 /**
  *  This function will connect to the database, execute a query and will return the result handle.
  *
  *  @param $sql The SQL statement to execute.
  *
  *  @returns    Handle to the result of the query.
  *
  *  @internal
  */
 function &_connectAndExec($sql)
 {
     // Add the table prefix
     $sql = str_replace(' #_', ' ' . YDConfig::get('YD_DB_TABLEPREFIX', ''), $sql);
     $sql = str_replace(' `#_', ' `' . YDConfig::get('YD_DB_TABLEPREFIX', ''), $sql);
     // Update the language placeholders
     $languageIndex = YDConfig::get('YD_DB_LANGUAGE_INDEX', null);
     if (!is_null($languageIndex)) {
         $sql = str_replace('_@', '_' . $languageIndex, $sql);
     }
     // Connect
     $result = $this->connect();
     // Handle errors
     if (!$result && is_null($this->_conn) && $this->_failOnError === true) {
         trigger_error(mysql_error(), YD_ERROR);
     }
     if (!$result && !is_null($this->_conn) && $this->_failOnError === true) {
         trigger_error(mysql_error($this->_conn), YD_ERROR);
     }
     // Record the start time
     $timer = new YDTimer();
     // Execute the query
     $result = @mysql_query($sql, $this->_conn);
     // Log the statement
     $this->_logSql($sql, $timer->getElapsed());
     // Handle errors
     if ($result === false) {
         $callback = YDConfig::get('YD_DB_ERROR_CALLBACK');
         // check if we should display the error or execute some callback
         if (is_string($callback) || is_array($callback)) {
             return call_user_func($callback, $sql, mysql_error($this->_conn), mysql_errno($this->_conn));
         } elseif ($callback === false && $this->_failOnError === true) {
             YDDebugUtil::error('[' . mysql_errno($this->_conn) . '] ' . mysql_error($this->_conn), $sql);
         }
     }
     // Return the result
     return $result;
 }