我有以下PHP类:
class SearchAttributeDao extends BaseDao
{
private $SELECT_CATEGORY_FILTER_BY_IDS;
function __construct()
{
$this->table_name = 'categoryattributes';
$this->SELECT_CATEGORY_ATTR_BY_IDS = "SELECT csa.attributeid, atn.name FROM "
.$this->table_name.
" csa join attributenames atn on csa.attributeid = atn.attributeid where csa.categoryid in (?); ";
}
public function getListByCatIds(array $catIds)
{
//...
$attr_list = $this->executeSelectQuery($this->SELECT_CATEGORY_FILTER_BY_IDS, [$catIds]); //Error on this line
//...
}
}
因此,当我执行我的应用程序时,我收到一条错误说明:
SQLSTATE [42000]:语法错误或访问冲突:1065查询为空(SQL :) ... 在BaseDao-> executeSelectQuery(null,array(array('10523','10524','10606','10423','10533','10618')))在SearchAttributeDao.php第24行
上面的堆栈跟踪表明SELECT_CATEGORY_FILTER_BY_IDS
为空或空,但我已在构造函数中设置它。我做错了什么?
答案 0 :(得分:2)
你在呼唤:
$this->executeSelectQuery($this->SELECT_CATEGORY_FILTER_BY_IDS..
但你已定义:
$this->SELECT_CATEGORY_ATTR_BY_IDS = "SELECT csa.attributeid,...
尝试更正名称,然后重试