现在我所做的是一个称为:
的功能public function TotalView($username)
{
$sql = "SELECT views from profile_views where username=:username";
$stmt = $this->con->prepare($sql);
$paramaters = [':username' => $username];
$stmt->execute($paramaters);
$count = $stmt->columnCount();
return $count;
}
现在它在个人资料页面中显示了Views:1。我有什么不对的吗? 编辑:用户saty修复了它。我应该使用$ count = $ stmt-> rowCount();. 而不是columnCount();
答案 0 :(得分:1)
返回结果集中的列数
反而使用
返回受上一个SQL语句影响的行数
<div class="color-picker">
<div class="well">
<button>Click here to pick a color</button>
Value:
<input />
</div>
<div class="well">
<button>Click here to pick a color</button>
Value:
<input />
</div>
<div class="well">
<button>Click here to pick a color</button>
Value:
<input />
</div>
<div class="well">
<button>Click here to pick a color</button>
Value:
<input />
</div>
<div class="well">
<button>Click here to pick a color</button>
Value:
<input />
</div>
</div>
<div class="right-block">
</div>
OR
您可以使用
$stmt->execute($paramaters);
$count = $stmt->rowCount();