- Posts: 2
- Thank you received: 0
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
- Topic Author
- Offline
- New Member
Less
More
4 years 7 months ago #188505
by siburuxue
在没有表前缀的时候引发了一个SQL错误 was created 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);
这样就可以了
如果$this->_connection->tablePrefix为空单不为null那么替换后的SQL可能包含保留关键字从而导致了SQL语法的错误,解决方案:
$this->_text=preg_replace('/{{(.*?)}}/','`'.$this->_connection->tablePrefix.'\1'.'`',$value);
这样就可以了
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13637
- Thank you received: 2491
4 years 7 months ago #188507
by DenisChenu
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.
Replied by DenisChenu on topic 在没有表前缀的时候引发了一个SQL错误
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
- Topic Author
- Offline
- New Member
Less
More
- Posts: 2
- Thank you received: 0
4 years 7 months ago #188522
by siburuxue
Replied by siburuxue on topic A SQL error occured during SQL executing when create tables without prefix
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。
$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
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13637
- Thank you received: 2491
4 years 7 months ago #188525
by DenisChenu
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.
Replied by DenisChenu on topic A SQL error occured during SQL executing when create tables without prefix
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.