我有一个简单的SELECT查询无法正常工作。它查询IS_VISIBLE = 1
的所有条目。在我的表格"部分"中,我目前有3条记录表示IS_VISIBLE = 1
,但我的页面只提取了2条记录
PHP代码:
<?php
date_default_timezone_set('America/Chicago');
$dsn = "mysql:host=localhost;dbname=********;charset=utf8";
$uname = "root";
$pword = "";
$db = null;
$limit = 10;
$counter = 0;
while (true) {
try {
$db = new PDO($dsn, $uname, $pword);
$db->exec( "SET CHARACTER SET utf8" );
$db->setAttribute( PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC );
$db->setAttribute( PDO::ATTR_PERSISTENT, true );
break;
}
catch (Exception $e) {
$db = null;
$counter++;
if ($counter == $limit)
throw $e;
}
}
$result = $db->prepare("SELECT PATH FROM `sections` WHERE IS_VISIBLE = 1");
$result->execute();
while ($row = $result->fetch(PDO::FETCH_ASSOC)){
$path_file=$row["PATH"];
echo include($path_file);
}
?>
这是我的表格和#34;部分&#34;在哪里可以看到有3条记录IS_VISIBLE = 1
,但我的代码只提取intro_video.php
和blog_widget.php
但不提取contacts.php
: