First off this is just plain silly
[php]mysqli_query($con,“UPDATE current_messages SET id=id+1 ORDER BY id DESC”);[/php]
There is no point in even having an order by, unless you’re going to use a limit. Since you’re updating everything just remove it.
[php]mysqli_query($con,“UPDATE current_messages SET id=id+1”);[/php]
Next I gave you a viable solution that’s more elegant and less error prone to what you’re trying to accomplish. You think in terms of only 1 person using you application and again that might be the case, but you never specified. I think in terms of many people using the application at once and which all your code and the way you have it designed isn’t going to work properly and occasionally you’re id’s sequence is going to be corrupted.
2 people use your application…
You do your little update statement, all Id’s are updated by 1. Then person 2 triggers the same routine, and then id’s are updated by 1 again. Now the first routine does the insert and then the second routine does the insert.
Now you have have a table with these ids (1,1,3,4,5,6,7,8) - You’re id’s are messed up with your 8, or perhaps your code errors out if your primary key is unique and crashes for the second user.
Now In PDO, a sql statement is a sql statement, if a sql statement works in mysqli that same statement will work in PDO. I don’t think the problem is what the sql statement, I think the problem is what how you are trying to execute your PDO statements.