SELECT d.* FROM as_downloads d LEFT JOIN as_categories c ON (d.download_category_id = c.category_id) WHERE d.download_category_id != -1 LIMIT 30
从
as_downloads
表,但不加入类别表。。
没有任何错误,我在PHPMyAdmin中测试过,结果是一样的,下面是使用的PHP代码
class Model_Downloads extends ModelType_PDO
{
public function fetchDownloads($limit)
{
$p = Registry::get('Config')->Database->prefix;
$query = "SELECT d.* FROM ".$p."downloads d LEFT JOIN ".$p."categories c ON d.download_category_id = c.category_id WHERE d.download_category_id != -1 LIMIT :limit";
$this->query = $this->prepare($query);
$this->query->bindValue(':limit',$limit,PDO::PARAM_INT);
if($this->query->execute())
{
return $this->query->fetchAll(PDO::FETCH_CLASS);
}
return false;
}
}