gpt4 book ai didi

php - 指定的列不在行中

转载 作者:行者123 更新时间:2023-11-29 12:52:12 24 4
gpt4 key购买 nike

我正在尝试检索表单,但每次尝试检索它时,我都会遇到此错误。

消息:指定的列“年份”不在行中

这是我的模型和表单代码。

型号

class Model_Periods extends Zend_Db_Table_Abstract
{
protected $_name = 'periods';
protected $_primary = 'id';

public function getPeriods()
{
//ZEND Distinct Quite Illusive
$select = $this->select()
->from($this, array('bus_year' => new Zend_Db_Expr('DISTINCT(bus_year)')))
->order('bus_year DESC');

$results = $this->fetchAll($select);
return $results;
}

表格:

<?php

class Form_Targets extends Zend_Form
{

public function init()
{
$available = $this->createElement('select', 'available');

$available->setlabel('Select a year to continue');
$available->setAttribs(array('class' => 'print the-font'));
$available->addDecorators(array(array('HtmlTag',array('tag' => 'dd', 'class' => 'ui-select print the-font ui-print' ))));
$available->setRequired(true);

$pMdl = new Model_Periods();
$periods = $pMdl->getPeriods();
$available->addmultiOption(0, 'Year' );
if ($periods->count() > 0)
{
foreach ($periods as $period)
{
$available->addmultiOption($period->year, $period->year);
}
}
$this->addElement($available);

}

}

最佳答案

您收到此错误是因为在使用 year 时,表中存在名为 bus_year 的字段。所以换行

$available->addmultiOption($period->year, $period->year);

$available->addmultiOption($period->bus_year, $period->bus_year);

关于php - 指定的列不在行中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24553709/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com