Example #1
0
 /**
  * @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);
 }
Example #2
0
 public function run($app)
 {
     $a = DB::tabApp()->find(1);
     print_r($a);
 }
Example #3
0
 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));
 }
Example #4
0
 public function testGetEm()
 {
     $em = DB::em();
     $this->assertInstanceOf('\\Doctrine\\ORM\\EntityManager', $em, 'DB::em() should be instance of \\Doctrine\\ORM\\EntityManager');
 }
Example #5
0
 private function getAnalyticsXml()
 {
     $categoriesVoting = DB::cache()->fetch('AdminAnalyticsCategoryVotes');
     if (empty($categoriesVoting)) {
         $categoriesVoting = DB::CategoryVote()->getAllFrontend();
         if (empty($categoriesVoting)) {
             $categoriesVoting = array();
         } else {
             DB::cache()->save('AdminAnalyticsCategoryVotes', $categoriesVoting, 120);
         }
     }
     $nomineesVoting = DB::cache()->fetch('AdminAnalyticsNomineeVotes');
     if (empty($nomineesVoting)) {
         $nomineesVoting = DB::NomineeVote()->getAnalyticsData();
         if (empty($nomineesVoting)) {
             $nomineesVoting = array();
         } else {
             DB::cache()->save('AdminAnalyticsNomineeVotes', $nomineesVoting, 120);
         }
     }
     $nominationVoting = DB::cache()->fetch('AdminAnalyticsNominationVotes');
     if (empty($nominationVoting)) {
         $nominationVoting = DB::Nomination()->getAnalyticsData();
         if (empty($nominationVoting)) {
             $nominationVoting = array();
         } else {
             DB::cache()->save('AdminAnalyticsNominationVotes', $nominationVoting, 120);
         }
     }
     App::$inst->config('templates.path', $this->analyticsXmlPath);
     $xml = App::$inst->view->fetch($this->analyticsXmlFile, array('categoriesVoting' => $categoriesVoting, 'nomineesVoting' => $nomineesVoting, 'nominationVoting' => $nominationVoting));
     $xmlmd5 = md5($xml);
     if (isset($this->state['xmlmd5']) && $this->state['xmlmd5'] != $xmlmd5) {
         $this->log('State was droped. Xml File changed');
         $this->dropState();
     }
     $this->state['xmlmd5'] = $xmlmd5;
     //        $xml = simplexml_load_string($xml);
     return $xml;
 }