Skip to content
Advertisement

Tag: php

MySQL query to extract first word from a field

I would like to run a query that returns the first word only from a particular field, this field has multiple words separated by spaces, I assume I may need to carry out some regex work to accomplish this? I know how to do this using a few ways in PHP but this would best be carried out on the

Getting a PDO query string with bound parameters without executing it

Is it possible to get a query string from a PDO object with bound parameters without executing it first? I have code similar to the following (where $dbc is the PDO object): Currently, this will echo out a SQL statement like: “SELECT * FROM users WHERE username = ?”. However, I would like to have the bound parameter included so

Advertisement