Elgg/Elgg — pull request #7294 by stianlik (2014-10-12 19:37:54+00:00)
Title: fix(database): More robust sql script execution.

Implemented tests for various formats of SQL input and fixed a bug that caused
text inside SQL strings to be interpreted as comments.

Example of input that would cause a problem:

```SQL
-- Input with a comment
INSERT INTO x VALUES ('Some string -- not a comment');
```
```PHP
// Operations in runSqlScript
// Fatal error
$this->updateData("INSERT INTO x VALUES ('Some value ");
```

By the additonal demand that all comments must start at the beginning of a line,
this problem is solved. Compared to the previous version, there is one case
that potentially could cause problems:

```SQL
-- Input with comment suffix
INSERT INTO x VALUES ('Some value'); -- Comment
```

```PHP
// Operations in runSqlScript
// No problem, we can pass comments into PHP MySQL API
$this->updateData("INSERT INTO x VALUES ('Some value'); -- Comment");
```
Luckily, the preceding example will execute as normal, so there should be no side-effects. The following example summarize supported comment formats in SQL files for patch.

```MYSQL
-- Supported comment will be stripped before executing statements
# Supported comment will be stripped before executing statements
/* Disregarded comment, will not be stripped, but is ignored by MySQL, should not be a problem */
INSERT INTO x VALUES ('Actual statement');
```