Im switching from good ol' MySQL
to MySQLi
(late bloomer, I know) and have chosen MySQLi
over PDO
.
Firstly, I like associative arrays (eg: $db_data['whatever_field'])
, so I cannot use prepared statements because that doesnt return associative arrays (by default / without workarounds).
So I have to manually prepare my MySQLi
statements myself, eg:
'SELECT * FROM admin_users WHERE email='. $mysqli->real_escape_string($_COOKIE['admin']['email']) .' AND password='. $mysqli->real_escape_string($_COOKIE['admin']['password']);
As you can imagine, this could get tiresome! Is there a short $mysqli->real_escape_string()
or what do you guys do?