What does the colon in a mysql statement mean? What does the colon in a mysql statement mean ?, $ Db-& gt; bandVars (); transfer value & nbsp; echo $ check_query; now you know ., Can you refer to the PHPcode & lt; of the pdo class in the manual ;? Php/* E what does the colon in mysql statements mean?
What does the colon in a mysql statement mean?
------ Solution --------------------
$ Db-> bandVars (); pass value
Echo $ check_query.
------ Solution --------------------
Let's take a look at the pdo class in the manual.
PHP code
Prepare ('select name, color, calories FROM fruit WHERE calories <: calories AND color =: color'); $……> bindParam (': calories', $ calories, PDO:: PARAM_INT); $……-> bindParam (': color', $ color, PDO: PARAM_STR, 12); $……-> execute ();?>
------ Solution --------------------
There are no other symbols to distinguish them from SQL syntax.
The bindVars method associates the defined symbols with the actual variables.
------ Solution --------------------
PHP code
Example #1 Execute a prepared statement with named placeholders
prepare('SELECT name, colour, calories FROM fruit WHERE calories < :calories AND colour = :colour');$sth->bindParam(':calories', $calories, PDO::PARAM_INT);$sth->bindParam(':colour', $colour, PDO::PARAM_STR, 12);$sth->execute();?>Example #2 Execute a prepared statement with question mark placeholders
prepare('SELECT name, colour, calories FROM fruit WHERE calories < ? AND colour = ?');$sth->bindParam(1, $calories, PDO::PARAM_INT);$sth->bindParam(2, $colour, PDO::PARAM_STR, 12);$sth->execute();?>