Db escape string: Difference between revisions From Online Manual

Jump to: navigation, search
(Created page with "{{smcfunc |function=db_escape_string |usage=$smcFunc['db_escape_string'] (uncleaned_string) |description=Escapes strings for insertion into the database. The function does not re...")
 
No edit summary
Line 13: Line 13:


<noinclude>
<noinclude>
[[Category:Database Functions]]
[[Category:Database Functions]]</noinclude>
[[Category:2.0]]
[[Category:Customizing SMF]]
[[Category:Developing SMF]]</noinclude>

Revision as of 21:48, 8 October 2012

Usage:

$smcFunc['db_escape_string'] (uncleaned_string)


Description: Escapes strings for insertion into the database. The function does not require a database connection.
For MySQL addslashes is used, while for PostgreSQL pg_escape_string and for SQLite sqlite_escape_string as used.

Parameters:

  • uncleaned_string the string to be escaped.

Return: the escaped string.

Example:

// Add slashes to every element, even the indexes!
foreach ($var as $k => $v)
	$new_var[$smcFunc['db_escape_string']($k)] = escapestring__recursive($v);



Advertisement: