当前位置: 首页>>代码示例>>PHP>>正文


PHP Migration类代码示例

本文整理汇总了PHP中Migration的典型用法代码示例。如果您正苦于以下问题:PHP Migration类的具体用法?PHP Migration怎么用?PHP Migration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Migration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: up

 function up()
 {
     echo "Starting Migration Proc ...<BR>";
     //check if migration already had ran ...
     $migration = DataObject::get_one("Migration", "Name='{$this->title}'");
     if (!$migration) {
         DB::getConn()->transactionStart();
         try {
             // migrate records from Live to Stage table
             DB::query("DELETE FROM JobPage");
             DB::query("\nINSERT INTO JobPage\n\t\t(ID,\n\t\tJobPostedDate,\n\t\tJobCompany,\n\t\tJobMoreInfoLink,\n\t\tJobLocation,\n\t\tFoundationJob,\n\t\tExpirationDate,\n\t\tActive,\n\t\tJobInstructions2Apply,\n\t\tLocationType,\n\t\tTitle,\n\t\tContent)\nSELECT \tJobPage_Live.ID,\n\t\tJobPostedDate,\n\t\tJobCompany,\n\t\tJobMoreInfoLink,\n\t\tJobLocation,\n\t\tFoundationJob,\n\t\tExpirationDate,\n\t\tActive,\n\t\tJobInstructions2Apply,\n\t\tLocationType,\n\t\tTitle,\n\t\tContent\nFROM  \tJobPage_Live\nINNER JOIN Page_Live on Page_Live.Id = JobPage_Live.Id\nINNER JOIN SiteTree_Live on SiteTree_Live.Id = JobPage_Live.Id");
             DB::query("DROP TABLE JobPage_Live");
             DB::query("DROP TABLE JobPage_versions");
             // delete orphan records
             DB::query("delete from Page where Id in (select Id from SiteTree where ClassName = 'JobPage')");
             DB::query("delete from SiteTree where ClassName = 'JobPage'");
             DB::query("delete from Page_Live where Id in (select Id from SiteTree_Live where ClassName = 'JobPage')");
             DB::query("delete from SiteTree_Live where ClassName = 'JobPage'");
             DB::query("delete from Page_versions where Id in (select Id from SiteTree_versions where ClassName = 'JobPage')");
             DB::query("delete from SiteTree_versions where ClassName = 'JobPage'");
             DB::getConn()->transactionEnd();
         } catch (Exception $e) {
             DB::getConn()->transactionRollback();
             return;
         }
         $migration = new Migration();
         $migration->Name = $this->title;
         $migration->Description = $this->description;
         $migration->Write();
     }
     echo "Ending  Migration Proc ...<BR>";
 }
开发者ID:OpenStackweb,项目名称:openstack-org,代码行数:32,代码来源:Live2StageJobMigrationTask.php

示例2: up

    function up()
    {
        echo "Starting  Proc ...<BR>";
        $migration = DataObject::get_one("Migration", "Name='{$this->title}'");
        if (!$migration) {
            $migration = new Migration();
            $migration->Name = $this->title;
            $migration->Description = $this->description;
            $migration->Write();
            //run migration
            $sql = <<<SQL
\t\tupdate DeploymentSurvey set InformationSources = REPLACE(InformationSources,'ask.openstack.org','Ask OpenStack (ask.openstack.org)')
where InformationSources like '%ask.openstack.org%';
SQL;
            DB::query($sql);
            $sql = <<<SQL
update Deployment set DeploymentStage = REPLACE(DeploymentStage,'Dev/QA','Under development/in testing')
where DeploymentStage like '%Dev/QA%';
SQL;
            DB::query($sql);
            $sql = <<<SQL
update Deployment set OtherWhyNovaNetwork = WhyNovaNetwork
where WhyNovaNetwork is not null;
SQL;
            DB::query($sql);
            $sql = <<<SQL
update Deployment set WhyNovaNetwork = 'Other (please specify)'
where OtherWhyNovaNetwork is not null;
SQL;
            DB::query($sql);
        } else {
            echo "Migration Already Ran! <BR>";
        }
        echo "Migration Done <BR>";
    }
开发者ID:OpenStackweb,项目名称:openstack-org,代码行数:35,代码来源:DeploymentSurveyMigration.php

示例3: up

 function up()
 {
     echo "Starting Migration Proc ...<BR>";
     //check if migration already had ran ...
     $migration = Migration::get()->filter('Name', $this->title)->first();
     if (!$migration) {
         $marketplace_types = array('Private Cloud');
         $factory = new MarketplaceFactory();
         $service = new MarketplaceTypeManager(new SapphireMarketPlaceTypeRepository(), new SapphireSecurityGroupRepository(), SapphireTransactionManager::getInstance());
         foreach ($marketplace_types as $marketplace_type) {
             try {
                 $service->store($factory->buildMarketplaceType($marketplace_type));
             } catch (Exception $ex) {
             }
         }
         DB::query("INSERT INTO CloudServiceOffered_PricingSchemas (CloudServiceOfferedID, PricingSchemaTypeID) SELECT PublicCloudServiceOfferedID, PricingSchemaTypeID FROM PublicCloudServiceOffered_PricingSchemas;");
         DB::query("UPDATE OpenStackImplementationApiCoverage SET ClassName='CloudServiceOffered'\nWHERE ImplementationID IN (SELECT ID FROM CompanyService where ClassName='PublicCloudService');");
         DB::query("UPDATE DataCenterRegion SET CloudServiceID = PublicCloudID;");
         DB::query("ALTER TABLE `CloudServiceOffered_PricingSchemas`\n\t\t\tADD UNIQUE INDEX `CloudServiceOffered_PricingSchemaType` (`CloudServiceOfferedID` ASC, `PricingSchemaTypeID` ASC);");
         DB::query("ALTER TABLE `DataCenterRegion` DROP INDEX `Name_PublicCloud`;");
         DB::query("ALTER TABLE `DataCenterRegion`\n\t\t\tADD UNIQUE INDEX `Name_CloudService` (`Name` ASC, `CloudServiceID` ASC);");
         $migration = new Migration();
         $migration->Name = $this->title;
         $migration->Description = $this->description;
         $migration->Write();
     }
     echo "Ending  Migration Proc ...<BR>";
 }
开发者ID:OpenStackweb,项目名称:openstack-org,代码行数:28,代码来源:NewMarketplaceTypePrivateCloudSeedTask.php

示例4: plugin_environment_install

function plugin_environment_install()
{
    global $DB;
    include_once GLPI_ROOT . "/plugins/environment/inc/profile.class.php";
    $update = false;
    if (TableExists("glpi_plugin_environment_profiles") && FieldExists("glpi_plugin_environment_profiles", "interface")) {
        $update = true;
        $DB->runFile(GLPI_ROOT . "/plugins/environment/sql/update-1.3.0.sql");
        $DB->runFile(GLPI_ROOT . "/plugins/environment/sql/update-1.4.0.sql");
    } else {
        if (TableExists("glpi_plugin_environment_profiles") && FieldExists("glpi_plugin_environment_profiles", "connections")) {
            $update = true;
            $DB->runFile(GLPI_ROOT . "/plugins/environment/sql/update-1.4.0.sql");
        }
    }
    if ($update) {
        //Do One time on 0.78
        $query_ = "SELECT *\n            FROM `glpi_plugin_environment_profiles` ";
        $result_ = $DB->query($query_);
        if ($DB->numrows($result_) > 0) {
            while ($data = $DB->fetch_array($result_)) {
                $query = "UPDATE `glpi_plugin_environment_profiles`\n                  SET `profiles_id` = '" . $data["id"] . "'\n                  WHERE `id` = '" . $data["id"] . "';";
                $result = $DB->query($query);
            }
        }
        $query = "ALTER TABLE `glpi_plugin_environment_profiles`\n               DROP `name` ;";
        $result = $DB->query($query);
    }
    PluginEnvironmentProfile::initProfile();
    PluginEnvironmentProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']);
    $migration = new Migration("1.8.0");
    $migration->dropTable('glpi_plugin_environment_profiles');
    $_SESSION["glpi_plugin_environment_installed"] = 1;
    return true;
}
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:35,代码来源:hook.php

示例5: actionCreate

 public function actionCreate()
 {
     $model = new Migration();
     $form = new Form('codegen.MigrationForm', $model);
     if ($form->submitted() && $model->validate()) {
         $res = Yii::app()->db->createCommand("SHOW CREATE TABLE {$model->table}")->queryRow();
         $sql = $res['Create Table'];
         $sql = explode("\n", $sql);
         foreach ($sql as $i => $str) {
             if ($i == 0) {
                 continue;
             }
             $sql[$i] = str_repeat(' ', 14) . $str;
         }
         $sql = implode("\n", $sql);
         $dir = APP_PATH . DS . 'modules' . DS . $model->module . DS . 'migrations' . DS;
         if (!is_dir($dir)) {
             mkdir($dir, 0777);
             chmod($dir, 0777);
         }
         $name = 'm' . date('ymd') . '_' . date('His') . '_' . $model->table . '_create';
         $file = $dir . $name . '.php';
         $params = array('name' => $name, 'table' => $model->table, 'sql' => $sql);
         $code = $this->renderPartial('codegen.views.templates.migration', $params, true);
         file_put_contents($file, $code);
         chmod($file, 0777);
         Yii::app()->user->setFlash('success', t('Создана миграция') . ' ' . $name);
     }
     $this->render('create', array('form' => $form));
 }
开发者ID:blindest,项目名称:Yii-CMS-2.0,代码行数:30,代码来源:MigrationAdminController.php

示例6: up

    function up()
    {
        echo "Starting Migration Proc ...<BR>";
        //check if migration already had ran ...
        $migration = Migration::get()->filter('Name', $this->title)->first();
        if (!$migration) {
            $SQL = <<<SQL
INSERT INTO `VideoPresentation`
(
`ClassName`,
`Created`,
`LastEdited`,
`Name`,
`DisplayOnSite`,
`Featured`,
`City`,
`Country`,
`Description`,
`YouTubeID`,
`URLSegment`,
`StartTime`,
`EndTime`,
`Location`,
`Type`,
`Day`,
`Speakers`,
`SlidesLink`,
`event_key`,
`IsKeynote`,
`PresentationCategoryPageID`,
`SummitID`,
`MemberID`)
SELECT 'VideoPresentation', NOW(),NOW(),Name, `DisplayOnSite`,
`Featured`,
`City`,
`Country`,
`Description`,
`YouTubeID`,
`URLSegment`,
`StartTime`,
`EndTime`,
`Location`,
`Type`,
`Day`,
`Speakers`,
`SlidesLink`,
`event_key`,
`IsKeynote`,
`PresentationCategoryPageID`,
`SummitID`,
`MemberID` FROM Presentation;
SQL;
            DB::query($SQL);
            $migration = new Migration();
            $migration->Name = $this->title;
            $migration->Description = $this->description;
            $migration->Write();
        }
        echo "Ending  Migration Proc ...<BR>";
    }
开发者ID:OpenStackweb,项目名称:openstack-org,代码行数:60,代码来源:FixVideoPageTask.php

示例7: plugin_ticketmail_install

function plugin_ticketmail_install()
{
    global $DB;
    $migration = new Migration(100);
    //Fresh install
    if (!TableExists('glpi_plugin_ticketmail_profiles')) {
        $query = "CREATE TABLE `glpi_plugin_ticketmail_profiles` (\n\t\t\t\t\t`id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_profiles (id)',\n\t\t\t\t\t`show_ticketmail_onglet` char(1) collate utf8_unicode_ci default NULL,\n\t\t\t\t\tPRIMARY KEY  (`id`)\n\t\t\t\t  ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
        $DB->queryOrDie($query, $DB->error());
        $migration->executeMigration();
        include_once GLPI_ROOT . "/plugins/ticketmail/inc/profile.class.php";
        PluginTicketmailProfile::createAdminAccess($_SESSION['glpiactiveprofile']['id']);
    } else {
        // Since v0.84 remove "profiles_id" column and use "id"
        if (FieldExists('glpi_plugin_ticketmail_profiles', 'profiles_id')) {
            $drop_column_query = "ALTER TABLE glpi_plugin_ticketmail_profiles DROP COLUMN `id`;";
            $rename_column_query = "ALTER TABLE glpi_plugin_ticketmail_profiles\n\t\t\t\t\t\t\t\t\tCHANGE profiles_id id int(11) NOT NULL default '0'\n\t\t\t\t\t\t\t\t\tCOMMENT 'RELATION to glpi_profiles (id)';";
            $DB->queryOrDie($drop_column_query, $DB->error());
            $DB->queryOrDie($rename_column_query, $DB->error());
            $add_primarykey_query = "ALTER TABLE glpi_plugin_ticketmail_profiles\n\t\t\t\t\t\t\t\t\t ADD PRIMARY KEY (id);";
            $drop_old_index_query = "ALTER TABLE glpi_plugin_ticketmail_profiles\n\t\t\t\t\t\t\t\t\t DROP INDEX profiles_id;";
            $DB->queryOrDie($add_primarykey_query, $DB->error());
            $DB->queryOrDie($drop_old_index_query, $DB->error());
        }
    }
    return true;
}
开发者ID:geldarr,项目名称:hack-space,代码行数:26,代码来源:hook.php

示例8: install

 /**
  * Install or update dropdowns
  *
  * @param Migration $migration Migration instance
  * @param string    $version   Plugin current version
  *
  * @return void
  */
 static function install(Migration $migration, $version)
 {
     $migration->displayMessage(__("Updating generated dropdown files", "fields"));
     // -> 0.90-1.3: generated class moved
     // OLD path: GLPI_ROOT."/plugins/fields/inc/$class_filename"
     // NEW path: PLUGINFIELDS_CLASS_PATH . "/$class_filename"
     // OLD path: GLPI_ROOT."/plugins/fields/front/$class_filename"
     // NEW path: PLUGINFIELDS_FRONT_PATH . "/$class_filename"
     $obj = new PluginFieldsField();
     $fields = $obj->find('type = "dropdown"');
     foreach ($fields as $field) {
         //First, drop old fields from plugin directories
         $class_filename = $field['name'] . "dropdown.class.php";
         if (file_exists(GLPI_ROOT . "/plugins/fields/inc/{$class_filename}")) {
             unlink(GLPI_ROOT . "/plugins/fields/inc/{$class_filename}");
         }
         $front_filename = $field['name'] . "dropdown.php";
         if (file_exists(GLPI_ROOT . "/plugins/fields/front/{$front_filename}")) {
             unlink(GLPI_ROOT . "/plugins/fields/front/{$front_filename}");
         }
         $form_filename = $field['name'] . "dropdown.form.php";
         if (file_exists(GLPI_ROOT . "/plugins/fields/front/{$form_filename}")) {
             unlink(GLPI_ROOT . "/plugins/fields/front/{$form_filename}");
         }
         //Second, create new files
         self::create($field);
     }
     return true;
 }
开发者ID:pluginsGLPI,项目名称:fields,代码行数:37,代码来源:dropdown.class.php

示例9: install

 static function install(Migration $migration)
 {
     global $DB;
     // Table no longer needed in GLPI 0.85+; drop it. Needed for upgrades
     $migration->dropTable(getTableForItemType(__CLASS__));
     PluginSimcardProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']);
 }
开发者ID:picaro04,项目名称:simcard,代码行数:7,代码来源:profile.class.php

示例10: _execute

 /**
  * Migrates the database to the version specified
  *
  * @param array $options Configuration to use
  */
 protected function _execute(array $options)
 {
     $groups = $options['group'];
     $target = $options['to'];
     $dry_run = $options['dry-run'] !== FALSE;
     $quiet = $options['quiet'] !== FALSE;
     $up = $options['up'] !== FALSE;
     $down = $options['down'] !== FALSE;
     $groups = $this->_parse_groups($groups);
     if ($target === NULL) {
         if ($down) {
             $target = FALSE;
         } else {
             $target = TRUE;
         }
     }
     $model = new Model_Migration();
     $model->ensure_table_exists();
     $manager = new Migration(NULL, $model);
     // Sync the available migrations with those in the db
     $manager->sync_migration_files()->set_dry_run($dry_run);
     try {
         // Run migrations for specified groups & versions
         $manager->run_migration($groups, $target);
     } catch (Migration_Exception $e) {
         echo View::factory('minion/db/exception')->set('migration', $e->get_migration())->set('error', $e->getMessage());
         throw $e;
     }
     $view = View::factory('minion/db/run')->set('dry_run', $dry_run)->set('quiet', $quiet)->set('dry_run_sql', $manager->get_dry_run_sql())->set('executed_migrations', $manager->get_executed_migrations())->set('group_versions', $model->get_group_statuses());
     return $view;
 }
开发者ID:MenZil-Team,项目名称:cms,代码行数:36,代码来源:migrate.php

示例11: up

 function up()
 {
     echo "Starting Migration Proc ...<BR>";
     //check if migration already had ran ...
     $migration = Migration::get()->filter('Name', $this->title)->first();
     if (!$migration) {
         $requests = JobRegistrationRequest::get();
         foreach ($requests as $request) {
             if (!empty($request->City)) {
                 //create locations
                 $location = new JobLocation();
                 $location->City = $request->City;
                 $location->State = $request->State;
                 $location->Country = $request->Country;
                 $location->RequestID = $request->ID;
                 $location->Write();
                 $request->LocationType = 'Various';
                 $request->Write();
             }
         }
         $migration = new Migration();
         $migration->Name = $this->title;
         $migration->Description = $this->description;
         $migration->Write();
     }
     echo "Ending  Migration Proc ...<BR>";
 }
开发者ID:OpenStackweb,项目名称:openstack-org,代码行数:27,代码来源:JobUpdateLocations.php

示例12: plugin_barcode_install

function plugin_barcode_install()
{
    global $DB;
    $migration = new Migration(PLUGIN_BARCODE_VERSION);
    if (!file_exists(GLPI_PLUGIN_DOC_DIR . "/barcode")) {
        mkdir(GLPI_PLUGIN_DOC_DIR . "/barcode");
    }
    $migration->renameTable("glpi_plugin_barcode_config", "glpi_plugin_barcode_configs");
    if (!TableExists("glpi_plugin_barcode_configs")) {
        $query = "CREATE TABLE `glpi_plugin_barcode_configs` (\n                  `id` int(11) NOT NULL auto_increment,\n                  `type` varchar(20) collate utf8_unicode_ci default NULL,\n                  PRIMARY KEY  (`ID`)\n               ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
        $DB->query($query) or die("error creating glpi_plugin_barcode_configs " . $DB->error());
        $query = "INSERT INTO `glpi_plugin_barcode_configs` \n                     (`id`, `type`)\n                VALUES\n                     ('1', 'code128')";
        $DB->query($query) or die("error populate glpi_plugin_barcode_configs " . $DB->error());
    }
    $migration->renameTable("glpi_plugin_barcode_config_type", "glpi_plugin_barcode_configs_types");
    if (!TableExists("glpi_plugin_barcode_configs_types")) {
        $query = "CREATE TABLE `glpi_plugin_barcode_configs_types` (\n                  `id` int(11) NOT NULL auto_increment,\n                  `type` varchar(20) collate utf8_unicode_ci default NULL,\n                  `size` varchar(20) collate utf8_unicode_ci default NULL,\n                  `orientation` varchar(9) collate utf8_unicode_ci default NULL,\n                  `marginTop` int(11) NULL,\n                  `marginBottom` int(11) NULL,\n                  `marginLeft` int(11) NULL,\n                  `marginRight` int(11) NULL,\n                  `marginHorizontal` int(11) NULL,\n                  `marginVertical` int(11) NULL,\n                  `maxCodeWidth` int(11) NULL,\n                  `maxCodeHeight` int(11) NULL,\n                  PRIMARY KEY  (`ID`),\n                  UNIQUE  (`type`)\n               ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
        $DB->query($query) or die("error creating glpi_plugin_barcode_configs_types " . $DB->error());
        $query = "INSERT INTO `glpi_plugin_barcode_configs_types`\n                     (`type`, `size`, `orientation`,\n                     `marginTop`, `marginBottom`, `marginLeft`, `marginRight`,\n                     `marginHorizontal`, `marginVertical`, `maxCodeWidth`, `maxCodeHeight`)\n                VALUES\n                     ('Code39', 'A4', 'Portrait',\n                     '30', '30', '30', '30',\n                     '25', '30', '128', '50'),\n                     ('code128', 'A4', 'Portrait',\n                     '30', '30', '30', '30',\n                     '25', '30', '110', '70'),\n                     ('ean13', 'A4', 'Portrait',\n                     '30', '30', '30', '30',\n                     '25', '30', '110', '70'),\n                     ('int25', 'A4', 'Portrait',\n                     '30', '30', '30', '30',\n                     '25', '30', '110', '70'),\n                     ('postnet', 'A4', 'Portrait',\n                     '30', '30', '30', '30',\n                     '25', '30', '110', '70'),\n                     ('upca', 'A4', 'Portrait',\n                     '30', '30', '30', '30',\n                     '25', '30', '110', '70'),\n                     ('QRcode', 'A4', 'Portrait',\n                     '30', '30', '30', '30',\n                     '25', '30', '110', '100')";
        $DB->query($query) or die("error populate glpi_plugin_barcode_configs_types " . $DB->error());
    }
    if (countElementsInTable("glpi_plugin_barcode_configs_types", "`type`='QRcode'") == 0) {
        $query = "INSERT INTO `glpi_plugin_barcode_configs_types`\n                     (`type`, `size`, `orientation`,\n                     `marginTop`, `marginBottom`, `marginLeft`, `marginRight`,\n                     `marginHorizontal`, `marginVertical`, `maxCodeWidth`, `maxCodeHeight`)\n                VALUES\n                     ('QRcode', 'A4', 'Portrait',\n                     '30', '30', '30', '30',\n                     '25', '30', '110', '100')";
        $DB->query($query) or die("error populate glpi_plugin_barcode_configs_types " . $DB->error());
    }
    include_once GLPI_ROOT . '/plugins/barcode/inc/profile.class.php';
    include_once GLPI_ROOT . '/plugins/barcode/inc/config.class.php';
    PluginBarcodeProfile::initProfile();
    if (TableExists("glpi_plugin_barcode_profiles")) {
        $query = "DROP TABLE `glpi_plugin_barcode_profiles`";
        $DB->query($query) or die("error deleting glpi_plugin_barcode_profiles");
    }
    return true;
}
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:34,代码来源:hook.php

示例13: up

    function up()
    {
        echo "Starting Migration Proc ...<BR>";
        //check if migration already had ran ...
        $migration = Migration::get()->filter('Name', $this->title)->first();
        if (!$migration) {
            $presentation_type = SummitEventType::get("SummitEventType", "Type = 'Presentation' AND SummitID = 5")->first();
            if ($presentation_type) {
                $presentation_type_id = $presentation_type->ID;
            } else {
                $presentation_type = new SummitEventType();
                $presentation_type->Type = 'Presentation';
                $presentation_type->SummitID = 5;
                $presentation_type->Color = '#D0A9F5';
                $presentation_type_id = $presentation_type->Write();
            }
            $SQL = <<<SQL
                UPDATE SummitEvent SET TypeID = {$presentation_type_id} WHERE ClassName = 'Presentation' AND SummitID = 5;
SQL;
            DB::query($SQL);
            $migration = new Migration();
            $migration->Name = $this->title;
            $migration->Description = $this->description;
            $migration->Write();
        }
        echo "Ending  Migration Proc ...<BR>";
    }
开发者ID:OpenStackweb,项目名称:openstack-org,代码行数:27,代码来源:SetPresentationEventType.php

示例14: plugin_vip_install

function plugin_vip_install()
{
    global $DB;
    $migration = new Migration(100);
    // Création de la table uniquement lors de la première installation
    if (!TableExists("glpi_plugin_vip_profiles")) {
        // Table des droits du profil
        $query = "CREATE TABLE `glpi_plugin_vip_profiles` (\n\t               `id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_profiles (id)',\n\t               `show_vip_tab` tinyint(1) collate utf8_unicode_ci default NULL,\n\t               PRIMARY KEY  (`id`)\n\t             ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
        $DB->query($query) or die("Error creating Vip Profiles table" . $DB->error());
        $migration->executeMigration();
        //creation du premier accès nécessaire lors de l'installation du plugin
        include_once GLPI_ROOT . "/plugins/vip/inc/profile.class.php";
        PluginVipProfile::createAdminAccess($_SESSION['glpiactiveprofile']['id']);
    }
    if (!TableExists("glpi_plugin_vip_groups")) {
        //
        $query = "CREATE TABLE `glpi_plugin_vip_groups` (\n                  `id` int(11) NOT NULL default 0 COMMENT 'RELATION to glpi_groups(id)',\n                  `isvip` tinyint(1) default '0',\n                  PRIMARY KEY (`id`)\n                ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
        $DB->query($query) or die("Erreur lors de la création de la table des groupes vip " . $DB->error());
        $query = "INSERT INTO `glpi_plugin_vip_groups`\n                  (`id`, `isvip`)\n                  VALUES ('0', '0')";
        $DB->query($query) or die("Erreur lors de l'insertion des valeurs par défaut dans la table des groupes vip " . $DB->error());
    }
    if (!TableExists("glpi_plugin_vip_tickets")) {
        $query = "CREATE TABLE glpi_plugin_vip_tickets (\n\t\t\t\t  id int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_tickets (id)',\n\t\t\t\t  isvip tinyint(1) default '0',\n\t\t\t\t  PRIMARY KEY (`id`)\n\t\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
        $DB->query($query) or die("Error creating Vip Tickets table");
    }
    $query = "INSERT INTO glpi_plugin_vip_tickets\n\t\t\t\t   SELECT id, '0'\n\t\t\t\t\t FROM glpi_tickets\n\t\t ON DUPLICATE KEY\n\t\t\t\t   UPDATE isvip = '0'";
    $DB->query($query) or die("Error inserting ticket in Vip Tickets table");
    $migration->executeMigration();
    return true;
}
开发者ID:geldarr,项目名称:hack-space,代码行数:30,代码来源:hook.php

示例15: createFromTable

 function createFromTable($tablename, $include_data = false, $where)
 {
     //check the table exists
     $db = $this->db;
     $query = 'SELECT relname FROM pg_class WHERE relname=' . $db->qstr($tablename);
     $result = $db->GetOne($query);
     if ($result === false) {
         throw new Exception('Cannot Create migration from table ' . $tablename . ' as it doesn\'t exist');
     }
     $migration = new Migration();
     $table = $migration->add(new CreateTableComponent());
     $table->name = $tablename;
     $references = $this->GetForeignKeys($tablename);
     $columns = $db->MetaColumns($tablename);
     foreach ($columns as $column_data) {
         $column_data->references = $references[$column_data->name];
         $column = new AddColumnComponent($column_data);
         $table->addColumn($column);
     }
     $pks = $db->MetaPrimaryKeys($tablename);
     $table->setPrimaryKeys($pks);
     if ($include_data) {
         $query = 'SELECT * FROM ' . $tablename . ($where != '' ? ' WHERE ' . $where : '');
         $insert_data = $migration->add(new InsertDataComponent($tablename));
         $insert_data->setDB($db);
         $result = $db->Execute($query) or die($db->ErrorMsg() . $query);
         foreach ($result as $key => $row) {
             $insert_data->addRow($row);
         }
     }
     return $migration->toArray();
 }
开发者ID:uzerpllp,项目名称:uzerp,代码行数:32,代码来源:MigrationCreator.php


注:本文中的Migration类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。