Aar*_*ley 4 php mysqli prepared-statement
我想使用mysqli/prepared语句计算下面的查询返回的记录数:
$mysql = new mysqli(DB_SERVER, DB_USER, DB_PASSWORD, DB_NAME) or die('There was a problem connecting to the database');
$stmt = $mysql->prepare('SELECT id,vcref,jobtitle,jobtype,jobintro,closingdate FROM jobs WHERE active = 1');
$stmt->execute();
$stmt->store_result;
$stmt->bind_result($id,$vcref,$jobtitle,$jobtype,$jobintro,$closingdate);
$stmt->fetch();
$totalLiveJobs = $stmt->num_rows();
Run Code Online (Sandbox Code Playgroud)
输出一致为0
您正在使用mysql_stmt_num_rows
OOP样式,因此将其称为函数是不正确的.尝试:
$stmt->num_rows;
Run Code Online (Sandbox Code Playgroud)
代替:
$stmt->num_rows();
Run Code Online (Sandbox Code Playgroud)
基本上,你正试图获得这个值:
class mysqli_stmt {
int num_rows
}
Run Code Online (Sandbox Code Playgroud)
也,
$stmt->store_result;
Run Code Online (Sandbox Code Playgroud)
应该:
$stmt->store_result();
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
11918 次 |
最近记录: |