0

I'm trying to rename a table with nativeQuery like this:

$rsm = new ResultSetMapping();
$query = $em->createNativeQuery('RENAME TABLE `'.$oldname.'` TO `'.$newname.'`', $rsm);
$result = $query->getResult();

Strangely the table gets renamed, but the last line throws an error:

Undefined offset: 1
.\vendor\doctrine\dbal\src\Driver\PDO\Exception.php:20
.\vendor\doctrine\dbal\src\Driver\PDO\Result.php:107
.\vendor\doctrine\dbal\src\Driver\PDO\Result.php:38
.\vendor\doctrine\dbal\src\Result.php:59

What am I missing?

Onki Hara
  • 270
  • 1
  • 9

1 Answers1

1

You try to execute DDL query like it would be a DML SELECT. There will be no result set as an outcome of such operation

assuming that $em is EntityManager do this

$em->getConnection()->executeQuery($yourQuery);

no ResultSetMapping nor other stuff anywhere.

Please be advised that this is not something I have tested myself nor I am active user of the Doctrine. I am convinced as for the cause, not if the snippet is a valid (googled it out)

Antoniossss
  • 31,590
  • 6
  • 57
  • 99