connection->executeQuery($sql)->fetch(); $count = $result['count']; if (!$count) { $unique = sha1(uniqid()); $sql = "INSERT INTO branch_sync (branch_name, unique_id, access_url_id) VALUES ('localhost', '$unique', '1')"; $this->addSql($sql); } } /** * @param Schema $schema */ public function down(Schema $schema) { $em = $this->getEntityManager(); $branchSync = $em ->getRepository('ChamiloCoreBundle:BranchSync') ->findOneBy([ 'branchName' => 'localhost', 'accessUrlId' => 1 ]); $em->remove($branchSync); $em->flush(); } }