What does the colon in a mysql statement mean? What does the colon in a mysql statement mean ?, $ Db-& gt; bandVars (); & nbsp; transfer value & nbsp; echo & nbsp; $ check_query; & nbsp; you will know ., Can you refer to the pdo class in the manual ;? Php/* & nbsp; what does the colon in the mysql statement 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.
/* Execute a prepared statement by binding PHP variables */
$calories = 150;
$colour = 'red';
$sth = $dbh->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();
?>
------ Solution --------------------
There are no other symbols to distinguish them from SQL syntax.
The bindVars method associates the defined symbols with the actual variables.
------ Solution --------------------
Example #1 Execute a prepared statement with named placeholders
/* Execute a prepared statement by binding PHP variables */
$calories = 150;
$colour = 'red';
$sth = $dbh->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
/* Execute a prepared statement by binding PHP variables */
$calories = 150;
$colour = 'red';
$sth = $dbh->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();
?>