我正在尝试从数据库中获取结果,但我的 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);
关于php - 具有多个 where 的 Joomla 查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29498804/