如何解决导出时出现SQL 1064错误?

问题描述 投票:0回答:0

我在这里使用 SQL 和 PHP oop,过程中遇到错误。

$query->select(array('TRIM(Concat(u.first_name," ",u.middle_name," ",u.last_name," ",
            u.suffix_name)) as name','a.title as institution',
            'u.institution_other','u.gender as sex','c.*','s.public_title'))
    ->from($db->quoteName('#__pm_submission_csf','c'))
    ->join('LEFT', $db->quoteName('#__pm_user_data', 'u') . ' ON ' . $db->quoteName('c.user_id') . ' = ' . $db->quoteName('u.user_id'))
    ->join('LEFT', $db->quoteName('#__pm_agencies', 'a') . ' ON ' . $db->quoteName('u.institution_id') . ' = ' . $db->quoteName('a.agency_id'))
    ->join('LEFT', $db->quoteName('#__pm_submission_data', 's') . ' ON ' . $db->quoteName('s.submission_id') . ' = ' . $db->quoteName('c.submission_id'))      
    ->where($db->quoteName('c.date_submitted > "' ). $date_start . '"')
    ->where($db->quoteName('c.date_submitted < "'). $date_end . '"')
    ->where($db->quoteName('c.csfqset_id') . '=' . (int) $csfqset_id)
    ->order($db->quoteName('c.date_submitted') . ' ASC');    
$db->setQuery($query);

这是我的代码,我遇到的错误是

1064 - 你的 SQL 语法有错误;检查与您的 MariaDB 服务器版本对应的手册,了解在第 7 行的“

" AND `c`.`date_submitted < "`" AND `c`.`csfqset_id`=327 ORDER BY `c`.`date_...
”附近使用的正确语法

我试过去掉indicate wrong syntax,没有报错但是不能过滤数据。数据库中的所有数据都在显示。我试图删除

$db->quoteName
但它仍然没有反映在页面中。

尝试使用特定的 date_start 和 date_end 在 excel 中导出

php mysql oop joomla
© www.soinside.com 2019 - 2024. All rights reserved.