So as MYSQL is deprecated and eveyone keeps telling me to update, I thought it was about time I did.
But as I'm not used to mysqli_*, it seems alien to me. And it's not a simple edit when I have a whole site coded in Mysql.
So I'm wondering: How would I transform the below code into Mysqli? Just to give me and anyone else a good starting point when dealing with querying the database.
$sql_follows="SELECT * FROM friends WHERE user1_id=".$_SESSION['id']." AND status=2 OR user2_id=".$_SESSION['id']." AND status=2";
$query_follows=mysql_query($sql_follows) or die("Error finding friendships");
if($query_follows>0){
}
EDIT: On reading up and editing my whole site the above code converted to MYSQLI_ would go something like this..
$Your_SQL_query_variable= mysqli_query($connectionvariable,"SELECT * FROM friends WHERE user1_id=".$_SESSION['id']." AND status=2 OR user2_id=".$_SESSION['id']." AND status=2")) {
printf("Error: %sn", $mysqli->error);
}
You can download a converter tool from here:
https://github.com/philip/MySQLConverterTool
The code it generates is pretty gross, mainly because of the way it implements the default database link argument with a
$GLOBAL
variable. (This also makes it easy to recognize when someone is using code that's gone through the converter.)There's also a MySQL Shim Library located here:
https://github.com/dshafik/php7-mysql-shim