I am executing manual prepared statements in my Doctrine migration. I am doing this as I require the last inserted ID to build further related queries. Using the standard addSql
method does not allow for this due to the nature of it "lining up" the queries and then executing them at the end.
Is there a way I can prevent the following error message from displaying?
Migration 20151102112832 was executed but did not result in any SQL statements.
There are many SQL statements executed, however they are execute when calling this method of mine:
/**
* @param string $sql
*
* @throws DBALException
*/
private function runSql($sql)
{
$this->write($sql);
$stmt = $this->connection->prepare($sql);
$stmt->execute();
}
You can create a "do nothing" sql:
public function up(Schema $schema)
{
$this->addSql('SELECT 1');
}
I think the best option here to show what your migration is doing. You can do this and suppress warning message by sending sql request with comment string. For example:
public function up(Schema $schema)
{
// Do not show warning on migrations.
$this->addSql('# Updating entities.');
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With