Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

A SQL error occured during SQL executing when create tables without prefix

  • siburuxue
  • siburuxue's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 7 months ago #188505 by siburuxue
在文件framework/db/CDbCommand.php中的第173行:$this->_text=preg_replace('/{{(.*?)}}/',$this->_connection->tablePrefix.'\1',$value);
如果$this->_connection->tablePrefix为空单不为null那么替换后的SQL可能包含保留关键字从而导致了SQL语法的错误,解决方案:
$this->_text=preg_replace('/{{(.*?)}}/','`'.$this->_connection->tablePrefix.'\1'.'`',$value);
这样就可以了
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 7 months ago #188507 by DenisChenu
I don't think we have a developer reading Chinese … can you translate (and explain) in english ?

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
  • siburuxue
  • siburuxue's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 7 months ago #188522 by siburuxue
In the file framework/db/CDbCommand.php,line 173:

$this->_text=preg_replace('/{{(.*?)}}/',$this->_connection->tablePrefix.'\1',$value);

if tables without prefix,'$this->_text' may be contains a classic words in the sql,`groups` for example.

so a sql error occured.

you can create a new project without prefix and create a new survey,after click the save button to jump a new page to show the survey list。
Code:
CDbCommand failed to execute the SQL statement: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'groups as question_groups WHERE questions.gid=question_groups.gid AND questions' at line 1
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 7 months ago #188525 by DenisChenu
OK,

Can you report the issue please ?
www.limesurvey.org/community/bug-tracker

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose