首页  >  文章  >  后端开发  >  mysql语句中的冒号是什么意思?该怎么解决

mysql语句中的冒号是什么意思?该怎么解决

WBOY
WBOY原创
2016-06-13 13:28:191788浏览

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


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

PHP code

<?php /* Execute a prepared statement by binding PHP variables */
$calories = 150;
$colour = 'red';
$sth = $dbh->prepare('SELECT name, colour, calories
    FROM fruit
    WHERE calories bindParam(':calories', $calories, PDO::PARAM_INT);
$sth->bindParam(':colour', $colour, PDO::PARAM_STR, 12);
$sth->execute();
?>
<br><font color="#e78608">------解决方案--------------------</font><br>没有别的意思符号而已,以便区别于 sql 的语法成分<br>bindVars 方法将定义的符号与实际的变量关联起来
<br><font color="#e78608">------解决方案--------------------</font><br>
PHP code
Example #1 Execute a prepared statement with named placeholders
<?php /* Execute a prepared statement by binding PHP variables */
$calories = 150;
$colour = 'red';
$sth = $dbh->prepare('SELECT name, colour, calories
    FROM fruit
    WHERE calories 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
<?php /* Execute a prepared statement by binding PHP variables */
$calories = 150;
$colour = 'red';
$sth = $dbh->prepare('SELECT name, colour, calories
    FROM fruit
    WHERE calories bindParam(1, $calories, PDO::PARAM_INT);
$sth->bindParam(2, $colour, PDO::PARAM_STR, 12);
$sth->execute();
?> <div class="clear">
                 
              
              
        
            </div>
声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn