Application\Migrations\Version20150314111201::postUp PHP Метод

postUp() публичный Метод

public postUp ( Doctrine\DBAL\Schema\Schema $schema )
$schema Doctrine\DBAL\Schema\Schema
    public function postUp(Schema $schema)
    {
        //$em = $this->container->get('doctrine.orm.entity_manager');
        $query = "SELECT * FROM UserMetadata";
        $stmt = $this->connection->prepare($query);
        $stmt->execute();
        $queryUpdate = "UPDATE users SET roles=:roles WHERE id=:userid";
        $stmtUpdate = $this->connection->prepare($queryUpdate);
        // We can't use Doctrine's ORM to fetch the item, because it has a load of extra fields
        // that aren't in the entity definition.
        while ($row = $stmt->fetch()) {
            //$user = $em->getRepository('BaikalSystemBundle:User')->find($row['userid']);
            $stmtUpdate->bindValue('roles', $row['roles']);
            $stmtUpdate->bindValue('userid', $row['userid']);
            $stmtUpdate->execute();
        }
        $queryDrop = "DROP TABLE UserMetadata";
        $stmtDrop = $this->connection->prepare($queryDrop);
        $stmtDrop->execute();
    }