I'm doing:
$truncateSQL = 'TRUNCATE TABLE :tableName';
$stmtTruncate = $em->getConnection()->prepare($truncateSQL);
$stmtTruncate->bindValue('tableName',$this->tableName);
$stmtTruncate->execute();
But getting the error:
[PDOException]
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 ''image_sizes_t'' at line 1
Are the quotes round the table name the problem here? $this->tableName
is just a string
You can't use table or column names in as placeholders in prepared statements as 'table_name'
is invalid MySql syntax.
if you need to make your column / table names safe you can wrap them in backticks.
"`".$table_name."`"