mysql語句中的冒號是什麼意思?
回複討論(解決方案)
$db->bandVars(); 傳遞值
echo $check_query; 就知道了。
可以看看手冊的pdo類
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 placeholdersprepare('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 placeholdersprepare('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();?>
大神,以下mysql 語句用來查詢排名,在Mysql 中能執行,但是S2SH 架構中就不行,你能指點一下嗎?
select t.*,@rownum:=@rownum+1 AS rownum
from (SELECT sum(yjb_yji) as total,yyryusername,yjb_yyry_id
FROM yjb where month(createtime) =month(now()) and year(createtime)=year(now())
group by yjb_yyry_id order by total desc) t,(SELECT @rownum:=0) r
報此bug: org.hibernate.QueryException: Space is not allowed after parameter prefix ':'