English 中文(简体)
严重违反《框架文件》的情况:1241年操作中应包含一栏。
原标题:Zend Framework Cardinality violation: 1241 Operand should contain 1 column(s)
  • 时间:2009-10-08 11:11:22
  •  标签:

我有一个棘手问题,我不知道如何解决这一问题,但我已经尝试过几个事情,但你知道。 因此,我要问:

    /**
 * 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;
 }
}

我的傲慢:

致命错误: 例外 Zend_Db_Statement_Exception with informSTATE[21,000]: 心脏病的违反:1241 操作中应包含一栏。

任何帮助?

问题回答

I had the same problem, finally I found that I was posting wrong value for a column. I was sending 2 values for a column. So, Check value of your parameters that are given to your function.

你们是否失踪? 查询表如下:

    /**
 * 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";
 $stmt = $db->query($q);
 $all = $stmt->fetchAll(); 
 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;
 }
}

我与你一样工作,但最后,我通过使用Zentd_Db_Select Object,而不是用问:

$select =  $this->getDbTable()->select(); // $this->select(); // 
$select->from( gallery ,  * );
$select->where( id_category = ? , $id_category);
$select->where( active , 1);

$resultSet = $this->getDbTable()->fetchAll($select);

Edited: Indented forcodeup show.

我有同样的问题。 这似乎是Zend Bug。

Source: http://framework.zend.com/issues/browse/ZF-3311





相关问题
热门标签