Rumah  >  Artikel  >  pembangunan bahagian belakang  >  mysql语句中的冒号是什么意义

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

WBOY
WBOYasal
2016-06-13 11:46:531966semak imbas

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

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

<br /><?php<br />/* Execute a prepared statement by binding PHP variables */<br />$calories = 150;<br />$colour = 'red';<br />$sth = $dbh->prepare('SELECT name, colour, calories<br />    FROM fruit<br />    WHERE calories < :calories AND colour = :colour');<br />$sth->bindParam(':calories', $calories, PDO::PARAM_INT);<br />$sth->bindParam(':colour', $colour, PDO::PARAM_STR, 12);<br />$sth->execute();<br />?> <br /><br /><br />

------解决方案--------------------
没有别的意思符号而已,以便区别于 sql 的语法成分
bindVars 方法将定义的符号与实际的变量关联起来
------解决方案--------------------
Example #1 Execute a prepared statement with named placeholders<br /><?php<br />/* Execute a prepared statement by binding PHP variables */<br />$calories = 150;<br />$colour = 'red';<br />$sth = $dbh->prepare('SELECT name, colour, calories<br />    FROM fruit<br />    WHERE calories < :calories AND colour = :colour');<br />$sth->bindParam(':calories', $calories, PDO::PARAM_INT);<br />$sth->bindParam(':colour', $colour, PDO::PARAM_STR, 12);<br />$sth->execute();<br />?><br />Example #2 Execute a prepared statement with question mark placeholders<br /><?php<br />/* Execute a prepared statement by binding PHP variables */<br />$calories = 150;<br />$colour = 'red';<br />$sth = $dbh->prepare('SELECT name, colour, calories<br />    FROM fruit<br />    WHERE calories < ? AND colour = ?');<br />$sth->bindParam(1, $calories, PDO::PARAM_INT);<br />$sth->bindParam(2, $colour, PDO::PARAM_STR, 12);<br />$sth->execute();<br />?>

Kenyataan:
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn