Can you tell me what's wrong with my MySql syntax?
$sql = "INSERT INTO :submissionTable (project_id) VALUES (:projectId)";
$sql2 = "INSERT INTO ".static::$_mSubmissionTableName." (project_id)
VALUES ('".$values[0]."')";
$database = DatabaseFactory::getFactory()->getConnection();
$query = $database->prepare($sql);
$result = $query->execute(array(
':submissionTable' => static::$_mSubmissionTableName,
':projectId' => $values[0]
));
Once I run this with $sql
I get this error:
Warning: PDOStatement::execute():
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
''submission' (project_id) VALUES ('1')' at line 1 in /app/model/ProjectModel.php on line 54
If I run the query with $sql2
and without parameters it executes and inserts desired values. What's wrong with the $sql
query?