PHP类(Zend Framework)中的返回错误
我在应用程序中使用ZF1,要生成报告,我的应用程序将返回一个错误: 我搜索了一下,但没有发现语法错误。你看到我班上的“return”有什么问题吗 我是这样做的: /application/models/DbTable/Pac.phpPHP类(Zend Framework)中的返回错误,php,mysql,zend-framework,Php,Mysql,Zend Framework,我在应用程序中使用ZF1,要生成报告,我的应用程序将返回一个错误: 我搜索了一下,但没有发现语法错误。你看到我班上的“return”有什么问题吗 我是这样做的: /application/models/DbTable/Pac.php class Application_Model_DbTable_Pac extends Fits_Db_Table { protected $_name = 'pac'; protected $_validate_fields = array (
class Application_Model_DbTable_Pac extends Fits_Db_Table
{
protected $_name = 'pac';
protected $_validate_fields = array (
'name',
);
public function getReport($month) {
$subselect = $this->select()
->from(['o'=>'orcamento'], ['pac_id'])
->join(['op' => 'orcamento_procedimento'], 'o.orcamento_id = op.orcamento_id', '')
->where('op.orcamento_procedimento_status_id = 4')
->where('op.especialidade = 5')
->where('op.deleted = 0')
->where('op.data_execucao >= DATE_SUB(NOW, INTERVAL '.$month.' MONTH)');
$select = $this->select()
->from('pac')
->where('ort_status_id = 2')
->where('pac_id NOT IN '.$subselect)
->order('name ASC');
return $this->fetchResult($select); //Line 51 informed in the error
}
...
class Default_PacController extends Fits_Controller_Action
{
public function reportAction() {
$this->_breadcrumb = array(
array('Home', '/', ''),
array('Pac', '', 'active'),
);
$this->_sessao = 1.4;
$dbPac = new Application_Model_DbTable_Pac();
$month = 1;
$report = $dbPac->getReport($month);
$this->view->pac = $report;
}
...
/application/modules/default/controllers/PacController.php
class Application_Model_DbTable_Pac extends Fits_Db_Table
{
protected $_name = 'pac';
protected $_validate_fields = array (
'name',
);
public function getReport($month) {
$subselect = $this->select()
->from(['o'=>'orcamento'], ['pac_id'])
->join(['op' => 'orcamento_procedimento'], 'o.orcamento_id = op.orcamento_id', '')
->where('op.orcamento_procedimento_status_id = 4')
->where('op.especialidade = 5')
->where('op.deleted = 0')
->where('op.data_execucao >= DATE_SUB(NOW, INTERVAL '.$month.' MONTH)');
$select = $this->select()
->from('pac')
->where('ort_status_id = 2')
->where('pac_id NOT IN '.$subselect)
->order('name ASC');
return $this->fetchResult($select); //Line 51 informed in the error
}
...
class Default_PacController extends Fits_Controller_Action
{
public function reportAction() {
$this->_breadcrumb = array(
array('Home', '/', ''),
array('Pac', '', 'active'),
);
$this->_sessao = 1.4;
$dbPac = new Application_Model_DbTable_Pac();
$month = 1;
$report = $dbPac->getReport($month);
$this->view->pac = $report;
}
...
/application/modules/default/views/scripts/pac/relat.phtml
...
<tr>
<th style="width:50%">Name</th>
<th style="width:14%">Last time</th>
</tr>
</thead>
<tbody>
<?foreach($this->relat as $v){?>
<tr>
<td style="vertical-align: middle"><?=isset($this->dados['ort_pac_name'])?></td>
<td style="vertical-align: middle" class="text-center"><?=$v['name']?></td>
</td>
</tr>
<?}?>
...
。。。
名称
上次
...
什么是完整的异常堆栈跟踪?此堆栈跟踪可能包含发生错误的来源。嗨,Marcel,当我在mysql中遇到错误时,堆栈跟踪刚刚为我返回。当我注释这一行(->order('name ASC');)p.ex时,只显示上面历史记录中显示的错误。异常信息:Message:SQLSTATE[42000]:语法错误或访问冲突:1064您的SQL语法有错误;检查与您的MySQL服务器版本对应的手册,以了解在日志文件的第1行堆栈跟踪:#0/var/www/html/library/Zend/Db/Statement.php(300):Zend_Db_Statement_Pdo->_execute(Array)…使用near')ORDER BYnome
ASC'的正确语法。。[Thu Apr 01 09:13:27.228547 2021][php7:emerg][pid 21373][client 127.0.0.1:52526]PHP解析错误:语法错误,第51行/var/www/html/application/models/DbTable/Pac.PHP中出现意外的“return”(T_return),请参考:我们找到了来源。您的sql查询字符串无效。尝试输出完整的sql查询字符串并研究它。我的第一个猜测是:您缺少子查询周围的括号。