To accompany the mysqli cheatsheet here is a PDO cheatsheet. Give me one record Give me the whole lot One row from user input using prepare Multiple rows from user input using prepare INSERT Get Last Insert ID UPDATE DELETE
Read MorePHP allows developers to reference variables dynamically. Take the following: The $myValue echos “medal” as normal. But when using the $$ double dollar prefix it outputs “Gold”. This is the value of the $medal variable. Dynamic variables like this can be very useful. Take a use case where you query a database using SELECT *…
Read MoreTo debug a mysqli prepare statement we could place the prepare statement within an if as follows: The above can help but it often you want to see the SQL that was created by the prepare statement. Unfortunately there is no easy way to do this. However, the function below might help. You can feed…
Read MoreNote: you might find these PHP functions do what you are after as well Getting Path Information with PHP This function is designed to return the file name called by a particular URL. It can also navigate up the URL to retrieve the parent directories if more of a path is needed in your application.…
Read MoreProject after project connecting to databases. What I need is a cheatsheet for the PHP MySQLi extension to cover the most common querying scenarios. Here we go: Give me one record Give me the whole lot One row from user input using prepare When you have variables coming via $_POST or $_GET ($_GET in this…
Read More