当前位置:Gxlcms > PHP教程 > mysql语句中的冒号是什么意义

mysql语句中的冒号是什么意义

时间:2021-07-01 10:21:17 帮助过:5人阅读

mysql语句中的冒号是什么意思?
mysql语句中的冒号是什么意思?

------解决方案--------------------
$db->bandVars(); 传递值
echo $check_query; 就知道了。
------解决方案--------------------
可以看看手册的pdo类

/* 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();
?>



------解决方案--------------------
没有别的意思符号而已,以便区别于 sql 的语法成分
bindVars 方法将定义的符号与实际的变量关联起来
------解决方案--------------------
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();
?>

人气教程排行