Security/Guides/SQL Queries and 3rd Party Packages

SQL Queries
Connecting your application and database layers can pose security risks. Notably, SQL injection. Below is an outline of the do's and dont's of executing SQL queries in MediaWiki.

Always Incorrect
MediaWiki developers should never directly execute SQL queries through PHP's database extension functions (such as mysql_query or pg_send_query).

Why? Directly inserting a SQL string in one of these provided functions makes the developer responsible for escaping the SQL string themselves. Otherwise, applications are susceptible to SQL injection attacks. https://www.php.net/manual/en/function.mysql-real-escape-string.php#refsect1-function.mysql-real-escape-string-examples

Custom Queries
IDatabase::query

De-Facto
IDatabase::select or IDatabase::insert

MW >1.35
SelectQueryBuilder