コード例 #1
0
def _query(query_, debug = 0):
  """
   Helper function for db_query().
  """
  if (lib_bootstrap.variable_get('dev_query', 0)):
    usec,sec = php.explode(' ', php.microtime())
    timer = float(usec) + float(sec)
    # If devel.plugin query logging is enabled, prepend a comment 
    # with the username and calling function
    # to the SQL string. This is useful when running mysql's 
    # SHOW PROCESSLIST to learn what exact
    # code is issueing the slow query.
    bt = debug_backtrace()
    # t() may not be available yet so we don't wrap 'Anonymous'
    name = (lib_appglobals.user.name if (lib_appglobals.user.uid > 0) else \
      variable_get('anonymous', 'Anonymous'))
    # php.str_replace() to prevent SQL injection via username
    # or anonymous name.
    name = php.str_replace(['*', '/'], '', name)
    query_ = '/* ' +  name  + ' : ' . bt[2]['function'] + ' */ ' + query_
  result = DrupyMySQL.mysqli_query(lib_appglobals.active_db, query_)
  if (lib_bootstrap.variable_get('dev_query', 0)):
    query_ = bt[2]['function'] +  "\n"  + query_
    usec,sec = php.explode(' ', php.microtime())
    stop = float(usec) + float(sec)
    diff = stop - timer
    lib_appglobals.queries.append( [query_, diff] )
  if (debug):
    print '<p>query: ' +  query_  + '<br />error:' + \
      DrupyMySQL.mysqli_error(lib_appglobals.active_db) + '</p>'
  if (not DrupyMySQL.mysqli_errno(lib_appglobals.active_db)):
    return result
  else:
    # Indicate to drupal_error_handler that this is a database error.
    DB_ERROR = True
    php.trigger_error(lib_bootstrap.check_plain(\
      DrupyMySQL.mysqli_error(lib_appglobals.active_db) +  \
      "\nquery: "  + query_), php.E_USER_WARNING)
    return False
コード例 #2
0
ファイル: database_mysqli.py プロジェクト: vaibbhav/drupy
def _query(query_, debug=0):
    """
   Helper function for db_query().
  """
    if (lib_bootstrap.variable_get('dev_query', 0)):
        usec, sec = php.explode(' ', php.microtime())
        timer = float(usec) + float(sec)
        # If devel.plugin query logging is enabled, prepend a comment
        # with the username and calling function
        # to the SQL string. This is useful when running mysql's
        # SHOW PROCESSLIST to learn what exact
        # code is issueing the slow query.
        bt = debug_backtrace()
        # t() may not be available yet so we don't wrap 'Anonymous'
        name = (lib_appglobals.user.name if (lib_appglobals.user.uid > 0) else \
          variable_get('anonymous', 'Anonymous'))
        # php.str_replace() to prevent SQL injection via username
        # or anonymous name.
        name = php.str_replace(['*', '/'], '', name)
        query_ = '/* ' + name + ' : '.bt[2]['function'] + ' */ ' + query_
    result = DrupyMySQL.mysqli_query(lib_appglobals.active_db, query_)
    if (lib_bootstrap.variable_get('dev_query', 0)):
        query_ = bt[2]['function'] + "\n" + query_
        usec, sec = php.explode(' ', php.microtime())
        stop = float(usec) + float(sec)
        diff = stop - timer
        lib_appglobals.queries.append([query_, diff])
    if (debug):
        print '<p>query: ' +  query_  + '<br />error:' + \
          DrupyMySQL.mysqli_error(lib_appglobals.active_db) + '</p>'
    if (not DrupyMySQL.mysqli_errno(lib_appglobals.active_db)):
        return result
    else:
        # Indicate to drupal_error_handler that this is a database error.
        DB_ERROR = True
        php.trigger_error(lib_bootstrap.check_plain(\
          DrupyMySQL.mysqli_error(lib_appglobals.active_db) +  \
          "\nquery: "  + query_), php.E_USER_WARNING)
        return False
コード例 #3
0
def error():
  """
   Determine whether the previous query caused an error.
  """
  return DrupyMySQL.mysqli_errno(lib_appglobals.active_db)
コード例 #4
0
ファイル: database_mysqli.py プロジェクト: vaibbhav/drupy
def error():
    """
   Determine whether the previous query caused an error.
  """
    return DrupyMySQL.mysqli_errno(lib_appglobals.active_db)