Example #1
0
 public function postDelete(Doctrine_Event $event)
 {
     //Make sure all linked tables are clean
     //RokGallery_Model_FileTags
     $q = Doctrine_Query::create()->delete('RokGallery_Model_FileTags ft')->andWhere('ft.file_id NOT IN (SELECT f.id from RokGallery_Model_File f)');
     $q->execute();
     $q->free();
     //RokGallery_Model_FileViews
     $q = Doctrine_Query::create()->delete('RokGallery_Model_FileViews fv')->andWhere('fv.file_id NOT IN (SELECT f.id from RokGallery_Model_File f)');
     $q->execute();
     $q->free();
     //RokGallery_Model_FileLoves
     $q = Doctrine_Query::create()->delete('RokGallery_Model_FileLoves fl')->andWhere('fl.file_id NOT IN (SELECT f.id from RokGallery_Model_File f)');
     $q->execute();
     $q->free();
     //rokgallery_files_index
     $conn =& Doctrine_Manager::connection();
     $dbh =& $conn->getDbh();
     $stmt = $dbh->prepare('delete from ' . RokCommon_Doctrine::getPlatformInstance()->setTableName('rokgallery_files_index') . ' where id NOT IN (SELECT f.id from ' . RokGallery_Model_FileTable::getInstance()->getTableName() . ' f)');
     $stmt->execute();
     //RokGallery_Model_Slice
     $q = Doctrine_Query::create()->delete('RokGallery_Model_Slice s')->andWhere('s.file_id NOT IN (SELECT f.id from RokGallery_Model_File f)');
     $q->execute();
     $q->free();
 }
 /**
  * @static
  * @return RokCommon_Doctrine
  */
 public static function getInstance()
 {
     if (!isset(self::$_instance)) {
         self::$_instance = new RokCommon_Doctrine();
     }
     return self::$_instance;
 }
Example #3
0
 protected function __construct()
 {
     parent::__construct();
     $migration = new RokGallery_Doctrine_Migration();
     if ($migration->getCurrentVersion() != $migration->getLatestVersion()) {
         $migration->migrate();
     }
     $this->connection->addListener(new RokGallery_Listener());
 }
Example #4
0
 /**
  * @param $tableName
  *
  * @internal param void $
  */
 public function setTableName($tableName)
 {
     parent::setTableName(RokCommon_Doctrine::getPlatformInstance()->setTableName($tableName));
 }
 public function preUp()
 {
     if (!$this->isInnoDBEngine(RokCommon_Doctrine::getPlatformInstance()->getSchema(), RokCommon_Doctrine::getPlatformInstance()->setTableName('rokgallery_files'))) {
         $this->run = true;
         //Clean up bad data
         //RokGallery_Model_FileTags
         $q = Doctrine_Query::create()->delete('RokGallery_Model_FileTags ft')->andWhere('ft.file_id NOT IN (SELECT f.id from RokGallery_Model_File f)');
         $q->execute();
         $q->free();
         //RokGallery_Model_FileViews
         $q = Doctrine_Query::create()->delete('RokGallery_Model_FileViews fv')->andWhere('fv.file_id NOT IN (SELECT f.id from RokGallery_Model_File f)');
         $q->execute();
         $q->free();
         //RokGallery_Model_FileLoves
         $q = Doctrine_Query::create()->delete('RokGallery_Model_FileLoves fl')->andWhere('fl.file_id NOT IN (SELECT f.id from RokGallery_Model_File f)');
         $q->execute();
         $q->free();
         //rokgallery_files_index
         $conn =& Doctrine_Manager::connection();
         $dbh =& $conn->getDbh();
         $stmt = $dbh->prepare('delete from ' . RokCommon_Doctrine::getPlatformInstance()->setTableName('rokgallery_files_index') . ' where id NOT IN (SELECT f.id from ' . RokGallery_Model_FileTable::getInstance()->getTableName() . ' f)');
         $stmt->execute();
         //RokGallery_Model_Slice
         $q = Doctrine_Query::create()->delete('RokGallery_Model_Slice s')->andWhere('s.file_id NOT IN (SELECT f.id from RokGallery_Model_File f)');
         $q->execute();
         $q->free();
         //RokGallery_Model_SliceTags
         $q = Doctrine_Query::create()->delete('RokGallery_Model_SliceTags st')->andWhere('st.slice_id NOT IN (SELECT s.id from RokGallery_Model_Slice s)');
         $q->execute();
         $q->free();
         //rokgallery_slices_index
         $stmt = $dbh->prepare('delete from ' . RokCommon_Doctrine::getPlatformInstance()->setTableName('rokgallery_slices_index') . ' where id NOT IN (SELECT s.id from ' . RokGallery_Model_SliceTable::getInstance()->getTableName() . ' s)');
         $stmt->execute();
         //RokGallery_Model_Gallery
         $q = Doctrine_Query::create()->update('RokGallery_Model_Slice')->set('gallery_id', 'NULL')->andWhere('gallery_id NOT IN (SELECT g.id from RokGallery_Model_Gallery g)');
         $q->execute();
         $q->free();
         $dbh->exec('alter table ' . RokCommon_Doctrine::getPlatformInstance()->setTableName('rokgallery_file_loves') . ' ENGINE=INNODB');
         $dbh->exec('alter table ' . RokCommon_Doctrine::getPlatformInstance()->setTableName('rokgallery_file_views') . ' ENGINE=INNODB');
         $dbh->exec('alter table ' . RokCommon_Doctrine::getPlatformInstance()->setTableName('rokgallery_file_tags') . ' ENGINE=INNODB');
         $dbh->exec('alter table ' . RokCommon_Doctrine::getPlatformInstance()->setTableName('rokgallery_files') . ' ENGINE=INNODB');
         $dbh->exec('alter table ' . RokCommon_Doctrine::getPlatformInstance()->setTableName('rokgallery_files_index') . ' ENGINE=INNODB');
         $dbh->exec('alter table ' . RokCommon_Doctrine::getPlatformInstance()->setTableName('rokgallery_filters') . ' ENGINE=INNODB');
         $dbh->exec('alter table ' . RokCommon_Doctrine::getPlatformInstance()->setTableName('rokgallery_galleries') . ' ENGINE=INNODB');
         $dbh->exec('alter table ' . RokCommon_Doctrine::getPlatformInstance()->setTableName('rokgallery_jobs') . ' ENGINE=INNODB');
         $dbh->exec('alter table ' . RokCommon_Doctrine::getPlatformInstance()->setTableName('rokgallery_profiles') . ' ENGINE=INNODB');
         $dbh->exec('alter table ' . RokCommon_Doctrine::getPlatformInstance()->setTableName('rokgallery_schema_version') . ' ENGINE=INNODB');
         $dbh->exec('alter table ' . RokCommon_Doctrine::getPlatformInstance()->setTableName('rokgallery_slice_tags') . ' ENGINE=INNODB');
         $dbh->exec('alter table ' . RokCommon_Doctrine::getPlatformInstance()->setTableName('rokgallery_slices') . ' ENGINE=INNODB');
         $dbh->exec('alter table ' . RokCommon_Doctrine::getPlatformInstance()->setTableName('rokgallery_slices_index') . ' ENGINE=INNODB');
     }
 }
 /**
  * Get the table name for storing the version number for this migration instance
  *
  * @return string $migrationTableName
  */
 public function getTableName()
 {
     return RokCommon_Doctrine::getPlatformInstance()->setTableName($this->_migrationTableName);
 }
Example #7
0
 /**
  * Add a add or remove index change.
  *
  * @param string $upDown       Whether to add the up(add) or down(remove) index change.
  * @param string $tableName    Name of the table
  * @param string $indexName    Name of the index
  * @param array  $definition   Array for the index definition
  *
  * @return void
  */
 public function index($upDown, $tableName, $indexName, array $definition = array())
 {
     parent::index($upDown, RokCommon_Doctrine::getPlatformInstance()->setTableName($tableName), $indexName, $definition);
 }