From the course: Learning phpMyAdmin

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Using named parameters in a query

Using named parameters in a query

From the course: Learning phpMyAdmin

Start my 1-month free trial

Using named parameters in a query

- A new feature in phpMyAdmin 4.5 allows you to use named parameters in the SQL tab. This can be very useful for testing PDO prepared statements because it uses the same syntax. I've opened the SQL tab in the cars table of the up_and_running database in phpMyAdmin 4.5. Let's run a simple query to select cars where the price is less than or equal to a particular value. So, we have to delete that WHERE 1, and then we'll make it WHERE 'price' then it will be <= but instead of putting in an actual value, I'm going to use a named parameter. Named parameters begin with a colon. You can call them what you like but I use the name of the column, price. Then we'll have an ORDER by clause and we'll use price as what we're ordering it by. Now, in the version of phpMyAdmin that I'm using, the query pane displays this cross in a red circle in the gutter and if we hover over it, it says there's an unexpected character near the colon. Now this obviously is not correct SQL but it does work. But to get…

Contents