带有多个where的Joomla查询


Joomla query with multiple where

我正在尝试从数据库中获取结果,但我的sql不是很好。

我在joomla3上,我想实现的是有一个来自多个类别的文章列表,我想按日期(而不是按类别)排列所有文章的结果,但"where"子句似乎不起作用。

这些是我迄今为止尝试过的查询,但没有人工作:

$query->select('id, title, introtext, created, created_by, images, urls');
$query->from('#__content');
//1st 'where' try
$query->where('catid=12'OR' catid=11'OR' catid=10');
//2nd 'where' try
$query->where('catid=12');
$query->OR('catid=11');
$query->OR('catid=10');
//3rd 'where' try
$query->where('catid = 11', 'OR')
->where('catid = 12');
$query->order('id DESC');

有什么迹象表明我做错了什么吗?感谢

在Joomla格式的查询编写中尝试一下

$query->select('id, title, introtext, created, created_by, images, urls'); 
$query->from('#__content');
$query->where('catid IN (10, 11, 12)'); //quotes fixed
$query->order('id DESC'); 
$db->setQuery($query);