好的,这是我的查询:
$db->sqlquery("
SELECT a.*, c.`category_name`
FROM `articles` a LEFT JOIN `articles_categorys` c
ON c.`category_id` = a.`category_id`
WHERE a.`active` = 1
AND a.`category_id` IN (?)
ORDER BY a.`date`
DESC LIMIT ?", array($config['article_rss_categorys'], $limit)
);
我检查了$config['article_rss_categorys']
is set and its 0,1,2,4,6,7
, also $limit
is set and it's 15
。
这是我的查询代码
try
{
$this->STH = $this->database->prepare($sql);
foreach($objects as $k=>$p)
{
// +1 is needed as arrays start at 0 where as ? placeholders start at 1 in PDO
if(is_numeric($p))
{
$this->STH->bindValue($k+1, $p, PDO::PARAM_INT);
}
else
{
$this->STH->bindValue($k+1, $p, PDO::PARAM_STR);
}
}
return $this->STH->execute();
$this->counter++;
}
catch (PDOException $e)
{
$core->message($e->getMessage());
}
我不明白为什么它失败了,我错过了什么愚蠢的东西吗?
我用正确的东西替换了 phpmyadmin 中的查询,?
它确实有效,所以数据库很好。
然后我尝试像这样获取并输出结果;
while ($line = $db->fetch())
{
// make date human readable
$date = $core->format_date($line['date']);
$output .= "
<item>
<title>{$line['category_name']} > {$line['title']}</title>
<link>http://www.prxa.info/index.php?module=articles_comments&aid={$line['article_id']}</link>
<pubDate>{$date}</pubDate>
<guid>http://www.prxa.info/index.php?module=articles_comments&aid={$line['article_id']}</guid>
</item>";
}
这是我的获取代码:
public function fetch()
{
$this->STH->setFetchMode(PDO::FETCH_ASSOC);
return $this->STH->fetch();
}