我有一个 sql 问题,我不知道如何解决它,我已经尝试了一些东西但是..你知道的。所以这是我的查询:
/**
* Returns a list with all the months for the archive
*
* @return array
*/
public function Archive()
{
$q = "SELECT DISTINCT MONTH(`data`) AS `month`,YEAR(`data`) AS `year` FROM `posts` ORDER BY `data` DESC";
$all = $this->fetchAll($q);
if (count($all) > 0) {
foreach ($all as $info) {
$months[] = array('month_name'=>$this->months($info['month']),'year'=>$info['year'],'month'=>$info['month']);
}
return $months;
}else{
return false;
}
}
还有我的错误:
Fatal error: Uncaught exception 'Zend_Db_Statement_Exception' with message 'SQLSTATE[21000]: Cardinality violation: 1241 Operand should contain 1 column(s)' in
有什么帮助吗?
最佳答案
我遇到了同样的问题,最后我发现我为一列发布了错误的值。我为一列发送了 2 个值。 因此,请检查提供给函数的参数值。
关于php - Zend 框架基数违规 : 1241 Operand should contain 1 column(s),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1537128/