Function DatabaseDriver->escape_string

Definitions

sources/database.php

  • Escape a string so it may be inserted into a query. If SQL statements are being built up and passed using db_query then it is essential that this is used for security reasons. Otherwise, the abstraction layer deals with the situation.
  • Visibility: public
  • Is abstract?: Yes
  • Is static?: No
  • Is final?: No
  • Returns: string

Parameters

Name Type Passed by reference? Variadic? Default Set Range Description
$string string No No required parameter N/A N/A The string

Returns

  • The escaped string
  • Type: string
  • Set: N/A
  • Range: N/A

Preview

Code (PHP)

/**
 * Escape a string so it may be inserted into a query. If SQL statements are being built up and passed using db_query then it is essential that this is used for security reasons. Otherwise, the abstraction layer deals with the situation.
 *
 * @param  string $string The string
 * @return string The escaped string
 */

abstract public function escape_string(string $string) : string