diff --git a/WordPress/Docs/DB/PreparedSQLStandard.xml b/WordPress/Docs/DB/PreparedSQLStandard.xml new file mode 100644 index 000000000..d58d61769 --- /dev/null +++ b/WordPress/Docs/DB/PreparedSQLStandard.xml @@ -0,0 +1,51 @@ + + + + prepare() to escape and quote the contents of variables. This prevents SQL injection. + Use placeholders for all variables used in the query. You should not use variable interpolation or concatenation. + ]]> + + + + prepare( + 'SELECT * from table + WHERE field = %s', + $_GET['foo'] +); + ]]> + + + query( + "SELECT * from table + WHERE field = {$_GET['foo']}" +); + ]]> + + + + + + prepare( + 'SELECT * from table + WHERE field = %s', + $value +); + ]]> + + + get_results( + "SELECT * from table + WHERE field = " . $value +); + ]]> + + +