我有一個簡單的語句,但似乎無法從select語句中獲取行數,當它真的很簡單時真的讓我感到困擾。我不斷得到空串。PHP-PDO,如何返回select語句中的行數
下面是代碼
include "connect.php";
$userID = $_POST['userID'];
$threadID = $_POST['threadID'];
$sql1 = "select * from AT_AddThread where AT_ID = :threadID";
$stmt = $conn->prepare($sql1);
$stmt->execute(array(':threadID' => $threadID));
$result = $stmt->fetchColumn(7);
//echo $result;
$sql2 = "select * from TJ_ThreadJoined where TJ_T_ID = :threadID"
$q2 = $conn->prepare($sql2);
$q2->execute(array(':threadID' => $threadID));
$q2->execute();
$rows = $q2->fetchColumn();
echo $rows; //THIS IS where i want to return the number of rows from the select statement
[查看手冊](http://php.net/manual/en/pdostatement.rowcount.php)對於'$ conn-> rowCount'雖然它不完全可靠,因爲它不起作用,所有數據庫引擎 – RiggsFolly
有一個方法:http://php.net/manual/en/pdostatement.rowcount.php,但不能保證與所有數據庫引擎一起工作。 – Koshinae
那麼一定有另一種方式呢? – redoc01