/** * @todo */ public function dbUpdate() { $success = true; try { $dummy = DB::em()->getConfiguration()->getMetadataDriverImpl(); $dummy->addPaths(array(APPLICATION_PATH . '/models')); $metadatas = DB::em()->getMetadataFactory()->getAllMetadata(); if (!empty($metadatas)) { $schemaTool = new \Doctrine\ORM\Tools\SchemaTool(DB::em()); $sqls = $schemaTool->getUpdateSchemaSql($metadatas, true); if (!empty($sqls)) { if (App::$inst->request->post('update')) { $schemaTool->updateSchema($metadatas, true); $message = 'Database schema updated successfully!'; } else { $message = 'List of updates:<br/>'; $message .= implode(';' . PHP_EOL, $sqls) . ';'; } } else { $message = 'SQLs are empty. Database schema is up to date'; } } else { $message = 'Database schema is up to date'; } } catch (Exception $e) { $success = false; $message = $e->getMessage() . $e->getTraceAsString(); } $this->jsonResponse($success, $message); }
public function testGetEm() { $em = DB::em(); $this->assertInstanceOf('\\Doctrine\\ORM\\EntityManager', $em, 'DB::em() should be instance of \\Doctrine\\ORM\\EntityManager'); }
protected function getCopy() { $db = class_exists('\\Application\\DB') ? \Application\DB::em() : \DB::em(); $query = $db->createQuery('SELECT c FROM \\Entity\\Copy c'); return $this->prepareArrayByLocales($query->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY)); }