我正在尝试使用 pdo 获取行数,如果数字小于 1 echo not found ,则执行其他操作。如果没有与 where 子句匹配的结果,则以下代码不会显示“未找到”。
$options = array(
'results_per_page' => 200,
'url' => 'index.php?page=*VAR*',
'db_handle' => $dbh
);
$page = $_GET['page'];
$paginate = new pagination($page, 'SELECT * FROM pants where size ="medium" or size ="M" ORDER BY id desc', $options);
$result = $paginate->resultset->fetchAll();
if($result > 0)
{
foreach($result as $row)
{
echo $row['title'];}
else {
echo "not found";}