symfony 框架报错Unknown relation aliass
程序员文章站
2022-06-16 15:00:15
...
就是这句代码报的错:
$q = Doctrine_Query::create()->from('FzAnswerquestionResult r')->leftJoin('r.FzUsers u ON r.fb_id = u.user_id')
->groupBy('r.fb_id')->where('r.is_delete = 0 and u.province = "'.$province.'" and r.end_time >= '.$starttime.' and r.end_time
500 | Internal Server Error | Doctrine_Table_Exception
Unknown relation alias FzUsers
stack trace
at ()
in SF_ROOT_DIR\lib\symfony\lib\plugins\sfDoctrinePlugin\lib\vendor\doctrine\Doctrine\Relation\Parser.php line 237 ...
return $this->getRelation($alias, false);
} else {
throw new Doctrine_Table_Exception('Unknown relation alias ' . $alias);
}
}
at Doctrine_Relation_Parser->getRelation('FzUsers', )
in SF_ROOT_DIR\lib\symfony\lib\plugins\sfDoctrinePlugin\lib\vendor\doctrine\Doctrine\Relation\Parser.php line 235 ...
at Doctrine_Relation_Parser->getRelation('FzUsers', 1)
in SF_ROOT_DIR\lib\symfony\lib\plugins\sfDoctrinePlugin\lib\vendor\doctrine\Doctrine\Table.php line 1001 ...
at Doctrine_Table->getRelation('FzUsers')
in SF_ROOT_DIR\lib\symfony\lib\plugins\sfDoctrinePlugin\lib\vendor\doctrine\Doctrine\Query.php line 1762 ...
at Doctrine_Query->load('r.FzUsers u ON r.fb_id = u.user_id')
in SF_ROOT_DIR\lib\symfony\lib\plugins\sfDoctrinePlugin\lib\vendor\doctrine\Doctrine\Query\From.php line 88 ...
at Doctrine_Query_From->parse('LEFT JOIN r.FzUsers u ON r.fb_id = u.user_id')
in SF_ROOT_DIR\lib\symfony\lib\plugins\sfDoctrinePlugin\lib\vendor\doctrine\Doctrine\Query\Abstract.php line 2084 ...
at Doctrine_Query_Abstract->_processDqlQueryPart('from', array('FzAnswerquestionResult r', 'LEFT JOIN r.FzUsers u ON r.fb_id = u.user_id'))
in SF_ROOT_DIR\lib\symfony\lib\plugins\sfDoctrinePlugin\lib\vendor\doctrine\Doctrine\Query.php line 1183 ...
at Doctrine_Query->buildSqlQuery()
in SF_ROOT_DIR\lib\symfony\lib\plugins\sfDoctrinePlugin\lib\vendor\doctrine\Doctrine\Query.php line 1149 ...
at Doctrine_Query->getSqlQuery(array(), )
in SF_ROOT_DIR\lib\symfony\lib\plugins\sfDoctrinePlugin\lib\vendor\doctrine\Doctrine\Query.php line 2042 ...
at Doctrine_Query->getCountSqlQuery()
in SF_ROOT_DIR\lib\symfony\lib\plugins\sfDoctrinePlugin\lib\vendor\doctrine\Doctrine\Query.php line 2132 ...
at Doctrine_Query->count()
in SF_ROOT_DIR\lib\model\doctrine\FzAnswerquestionResult.class.php line 400 ...
at FzAnswerquestionResult->getFbThisIssueUserNumByProvince('北京', 1388332800, 1397475117)
in SF_ROOT_DIR\apps\frontend\modules\exam\actions\actions.class.php line 1313 ...
at examActions->executeFbExamProvinceRank(object('sfWebRequest'))
in SF_ROOT_DIR\lib\symfony\lib\action\sfActions.class.php line 60 ...
}
// run action
return $this->$actionToRun($request);
}
}
at sfActions->execute(object('sfWebRequest'))
in SF_ROOT_DIR\lib\symfony\lib\filter\sfExecutionFilter.class.php line 92 ...
at sfExecutionFilter->executeAction(object('examActions'))
in SF_ROOT_DIR\lib\symfony\lib\filter\sfExecutionFilter.class.php line 78 ...
at sfExecutionFilter->handleAction(object('sfFilterChain'), object('examActions'))
in SF_ROOT_DIR\lib\symfony\lib\filter\sfExecutionFilter.class.php line 53 ...
at sfExecutionFilter->execute(object('sfFilterChain'))
in SF_ROOT_DIR\lib\symfony\lib\filter\sfFilterChain.class.php line 53 ...
at sfFilterChain->execute()
in SF_ROOT_DIR\lib\symfony\lib\filter\sfRenderingFilter.class.php line 33 ...
at sfRenderingFilter->execute(object('sfFilterChain'))
in SF_ROOT_DIR\lib\symfony\lib\filter\sfFilterChain.class.php line 53 ...
at sfFilterChain->execute()
in SF_ROOT_DIR\lib\symfony\lib\controller\sfController.class.php line 238 ...
at sfController->forward('exam', 'FbExamProvinceRank')
in SF_ROOT_DIR\lib\symfony\lib\controller\sfFrontWebController.class.php line 48 ...
at sfFrontWebController->dispatch()
in SF_ROOT_DIR\lib\symfony\lib\util\sfContext.class.php line 170 ...
at sfContext->dispatch()
in SF_ROOT_DIR\web\index.php line 7 ...
symfony settings ...
request ...
response ...
user ...
global vars ...
symfony v.1.4.17 - php 5.2.6
for help resolving this issue, please visit http://www.symfony-project.org/.
回复内容:
就是这句代码报的错:
$q = Doctrine_Query::create()->from('FzAnswerquestionResult r')->leftJoin('r.FzUsers u ON r.fb_id = u.user_id')
->groupBy('r.fb_id')->where('r.is_delete = 0 and u.province = "'.$province.'" and r.end_time >= '.$starttime.' and r.end_time
500 | Internal Server Error | Doctrine_Table_Exception
Unknown relation alias FzUsers
stack trace
at ()
in SF_ROOT_DIR\lib\symfony\lib\plugins\sfDoctrinePlugin\lib\vendor\doctrine\Doctrine\Relation\Parser.php line 237 ...
return $this->getRelation($alias, false);
} else {
throw new Doctrine_Table_Exception('Unknown relation alias ' . $alias);
}
}
at Doctrine_Relation_Parser->getRelation('FzUsers', )
in SF_ROOT_DIR\lib\symfony\lib\plugins\sfDoctrinePlugin\lib\vendor\doctrine\Doctrine\Relation\Parser.php line 235 ...
at Doctrine_Relation_Parser->getRelation('FzUsers', 1)
in SF_ROOT_DIR\lib\symfony\lib\plugins\sfDoctrinePlugin\lib\vendor\doctrine\Doctrine\Table.php line 1001 ...
at Doctrine_Table->getRelation('FzUsers')
in SF_ROOT_DIR\lib\symfony\lib\plugins\sfDoctrinePlugin\lib\vendor\doctrine\Doctrine\Query.php line 1762 ...
at Doctrine_Query->load('r.FzUsers u ON r.fb_id = u.user_id')
in SF_ROOT_DIR\lib\symfony\lib\plugins\sfDoctrinePlugin\lib\vendor\doctrine\Doctrine\Query\From.php line 88 ...
at Doctrine_Query_From->parse('LEFT JOIN r.FzUsers u ON r.fb_id = u.user_id')
in SF_ROOT_DIR\lib\symfony\lib\plugins\sfDoctrinePlugin\lib\vendor\doctrine\Doctrine\Query\Abstract.php line 2084 ...
at Doctrine_Query_Abstract->_processDqlQueryPart('from', array('FzAnswerquestionResult r', 'LEFT JOIN r.FzUsers u ON r.fb_id = u.user_id'))
in SF_ROOT_DIR\lib\symfony\lib\plugins\sfDoctrinePlugin\lib\vendor\doctrine\Doctrine\Query.php line 1183 ...
at Doctrine_Query->buildSqlQuery()
in SF_ROOT_DIR\lib\symfony\lib\plugins\sfDoctrinePlugin\lib\vendor\doctrine\Doctrine\Query.php line 1149 ...
at Doctrine_Query->getSqlQuery(array(), )
in SF_ROOT_DIR\lib\symfony\lib\plugins\sfDoctrinePlugin\lib\vendor\doctrine\Doctrine\Query.php line 2042 ...
at Doctrine_Query->getCountSqlQuery()
in SF_ROOT_DIR\lib\symfony\lib\plugins\sfDoctrinePlugin\lib\vendor\doctrine\Doctrine\Query.php line 2132 ...
at Doctrine_Query->count()
in SF_ROOT_DIR\lib\model\doctrine\FzAnswerquestionResult.class.php line 400 ...
at FzAnswerquestionResult->getFbThisIssueUserNumByProvince('北京', 1388332800, 1397475117)
in SF_ROOT_DIR\apps\frontend\modules\exam\actions\actions.class.php line 1313 ...
at examActions->executeFbExamProvinceRank(object('sfWebRequest'))
in SF_ROOT_DIR\lib\symfony\lib\action\sfActions.class.php line 60 ...
}
// run action
return $this->$actionToRun($request);
}
}
at sfActions->execute(object('sfWebRequest'))
in SF_ROOT_DIR\lib\symfony\lib\filter\sfExecutionFilter.class.php line 92 ...
at sfExecutionFilter->executeAction(object('examActions'))
in SF_ROOT_DIR\lib\symfony\lib\filter\sfExecutionFilter.class.php line 78 ...
at sfExecutionFilter->handleAction(object('sfFilterChain'), object('examActions'))
in SF_ROOT_DIR\lib\symfony\lib\filter\sfExecutionFilter.class.php line 53 ...
at sfExecutionFilter->execute(object('sfFilterChain'))
in SF_ROOT_DIR\lib\symfony\lib\filter\sfFilterChain.class.php line 53 ...
at sfFilterChain->execute()
in SF_ROOT_DIR\lib\symfony\lib\filter\sfRenderingFilter.class.php line 33 ...
at sfRenderingFilter->execute(object('sfFilterChain'))
in SF_ROOT_DIR\lib\symfony\lib\filter\sfFilterChain.class.php line 53 ...
at sfFilterChain->execute()
in SF_ROOT_DIR\lib\symfony\lib\controller\sfController.class.php line 238 ...
at sfController->forward('exam', 'FbExamProvinceRank')
in SF_ROOT_DIR\lib\symfony\lib\controller\sfFrontWebController.class.php line 48 ...
at sfFrontWebController->dispatch()
in SF_ROOT_DIR\lib\symfony\lib\util\sfContext.class.php line 170 ...
at sfContext->dispatch()
in SF_ROOT_DIR\web\index.php line 7 ...
symfony settings ...
request ...
response ...
user ...
global vars ...
symfony v.1.4.17 - php 5.2.6
for help resolving this issue, please visit http://www.symfony-project.org/.
http://docs.doctrine-project.org/en/2.0.x/reference/query-builder.html
应该是这样的吧:
Doctrine_Query::create()
->from('FzAnswerquestionResult r')
->leftJoin('r.FzUsers', 'u')
上一篇: mysql的中文数据按拼音排序的2个方法_MySQL
下一篇: 新手程序员的快速成长之道