• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Migration类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: install

/**
 * Install
 *
 * @return bool for success (will die for most error)
 * */
function install()
{
    global $DB;
    $migration = new Migration(100);
    // Install script
    $DB->runFile(GLPI_ROOT . "/plugins/consumables/install/sql/empty-1.0.0.sql");
    // Notification
    // Request
    $query_id = "INSERT INTO `glpi_notificationtemplates`(`name`, `itemtype`, `date_mod`, `comment`, `css`) VALUES ('Consumables Request','PluginConsumablesRequest', NOW(),'','');";
    $result = $DB->query($query_id) or die($DB->error());
    $query_id = "SELECT `id` FROM `glpi_notificationtemplates` WHERE `itemtype`='PluginConsumablesRequest' AND `name` = 'Consumables Request'";
    $result = $DB->query($query_id) or die($DB->error());
    $itemtype = $DB->result($result, 0, 'id');
    $query = "INSERT INTO `glpi_notificationtemplatetranslations`\r\nVALUES(NULL, '" . $itemtype . "', '','##consumable.action## : ##consumable.entity##',\r\n'##lang.consumable.entity## :##consumable.entity##\r\n##lang.consumablerequest.requester## : ##consumablerequest.requester##\t\r\n##lang.consumablerequest.consumabletype## : ##consumablerequest.consumabletype##\t\r\n##lang.consumablerequest.consumable## : ##consumablerequest.consumable##\r\n##lang.consumablerequest.number## : ##consumablerequest.number##\r\n##lang.consumablerequest.request_date## : ##consumablerequest.request_date##\r\n##lang.consumablerequest.status## : ##consumablerequest.status##',\r\n'&lt;p&gt;##lang.consumable.entity## :##consumable.entity##&lt;br /&gt; &lt;br /&gt;\r\n##lang.consumablerequest.requester## : ##consumablerequest.requester##&lt;br /&gt;\t\r\n##lang.consumablerequest.consumabletype## : ##consumablerequest.consumabletype##&lt;br /&gt;\r\n##lang.consumablerequest.consumable## : ##consumablerequest.consumable##&lt;br /&gt;\r\n##lang.consumablerequest.number## : ##consumablerequest.number##&lt;br /&gt;\r\n##lang.consumablerequest.request_date## : ##consumablerequest.request_date##&lt;br /&gt;\r\n##lang.consumablerequest.status## : ##consumablerequest.status##&lt;br /&gt;');";
    $result = $DB->query($query);
    $query = "INSERT INTO `glpi_notifications`\r\n              VALUES (NULL, 'Consumable request', 0, 'PluginConsumablesRequest', 'ConsumableRequest',\r\n                     'mail','" . $itemtype . "', '', 1, 1, '" . date('Y-m-d H:i:s') . "');";
    $result = $DB->query($query);
    // Request validation
    $query_id = "INSERT INTO `glpi_notificationtemplates`(`name`, `itemtype`, `date_mod`, `comment`, `css`) VALUES ('Consumables Request Validation','PluginConsumablesRequest', NOW(),'','');";
    $result = $DB->query($query_id) or die($DB->error());
    $query_id = "SELECT `id` FROM `glpi_notificationtemplates` WHERE `itemtype`='PluginConsumablesRequest' AND `name` = 'Consumables Request Validation'";
    $result = $DB->query($query_id) or die($DB->error());
    $itemtype = $DB->result($result, 0, 'id');
    $query = "INSERT INTO `glpi_notificationtemplatetranslations`\r\nVALUES(NULL, '" . $itemtype . "', '','##consumable.action## : ##consumable.entity##',\r\n'##lang.consumable.entity## :##consumable.entity##\r\n##lang.consumablerequest.requester## : ##consumablerequest.requester##\t\r\n##lang.consumablerequest.validator## : ##consumablerequest.validator##\t\r\n##lang.consumablerequest.consumabletype## : ##consumablerequest.consumabletype##\t\r\n##lang.consumablerequest.consumable## : ##consumablerequest.consumable##\r\n##lang.consumablerequest.number## : ##consumablerequest.number##\r\n##lang.consumablerequest.request_date## : ##consumablerequest.request_date##\r\n##lang.consumablerequest.status## : ##consumablerequest.status##\r\n##lang.consumablerequest.comment## : ##consumablerequest.comment##',\r\n'&lt;p&gt;##lang.consumable.entity## :##consumable.entity##&lt;br /&gt; &lt;br /&gt;\r\n##lang.consumablerequest.requester## : ##consumablerequest.requester##&lt;br /&gt;\t\r\n##lang.consumablerequest.validator## : ##consumablerequest.validator##&lt;br /&gt;\r\n##lang.consumablerequest.consumabletype## : ##consumablerequest.consumabletype##&lt;br /&gt;\r\n##lang.consumablerequest.consumable## : ##consumablerequest.consumable##&lt;br /&gt;\r\n##lang.consumablerequest.number## : ##consumablerequest.number##&lt;br /&gt;\r\n##lang.consumablerequest.request_date## : ##consumablerequest.request_date##&lt;br /&gt;\r\n##lang.consumablerequest.status## : ##consumablerequest.status##&lt;br /&gt;\r\n##lang.consumablerequest.comment## : ##consumablerequest.comment##&lt;br /&gt;');";
    $result = $DB->query($query);
    $query = "INSERT INTO `glpi_notifications`\r\n              VALUES (NULL, 'Consumable request validation', 0, 'PluginConsumablesRequest', 'ConsumableResponse',\r\n                     'mail','" . $itemtype . "','', 1, 1, '" . date('Y-m-d H:i:s') . "');";
    $result = $DB->query($query);
    $migration->executeMigration();
    return true;
}
开发者ID:AircraftRu,项目名称:consumables,代码行数:35,代码来源:install.php


示例17: plugin_moreticket_install

function plugin_moreticket_install()
{
    global $DB;
    include_once GLPI_ROOT . "/plugins/moreticket/inc/profile.class.php";
    if (!TableExists("glpi_plugin_moreticket_configs")) {
        // table sql creation
        $DB->runFile(GLPI_ROOT . "/plugins/moreticket/sql/empty-1.2.0.sql");
    }
    PluginMoreticketProfile::initProfile();
    PluginMoreticketProfile::createFirstAccess($_SESSION['glpiactiveprofile']['id']);
    $migration = new Migration("1.1.0");
    $migration->dropTable('glpi_plugin_moreticket_profiles');
    if (!FieldExists("glpi_plugin_moreticket_configs", "solution_status")) {
        $DB->runFile(GLPI_ROOT . "/plugins/moreticket/sql/update-1.1.1.sql");
    }
    if (FieldExists("glpi_plugin_moreticket_waitingtypes", "is_helpdeskvisible")) {
        $DB->runFile(GLPI_ROOT . "/plugins/moreticket/sql/update-1.1.2.sql");
    }
    if (!FieldExists("glpi_plugin_moreticket_closetickets", "documents_id")) {
        $DB->runFile(GLPI_ROOT . "/plugins/moreticket/sql/update-1.1.3.sql");
    }
    if (!FieldExists("glpi_plugin_moreticket_configs", "date_report_mandatory")) {
        $DB->runFile(GLPI_ROOT . "/plugins/moreticket/sql/update-1.2.0.sql");
    }
    return true;
}
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:26,代码来源:hook.php


示例18: install

 public static function install(Migration $migration)
 {
     global $DB;
     $table = getTableForItemType(__CLASS__);
     if (!TableExists($table)) {
         $query = "CREATE TABLE IF NOT EXISTS `{$table}` (\n                     `id` int(11) NOT NULL auto_increment,\n                     `entities_id` int(11) NOT NULL DEFAULT '0',\n                     `is_recursive` tinyint(1) NOT NULL DEFAULT '1',\n                     `name` varchar(255) NOT NULL DEFAULT '',\n                     `comment` text collate utf8_unicode_ci,\n                     `color` varchar(50) NOT NULL DEFAULT '' COLLATE 'utf8_unicode_ci',\n                     PRIMARY KEY (`id`),\n                     KEY `name` (`name`)\n                     ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
         $GLOBALS['DB']->query($query) or die($GLOBALS['DB']->error());
     }
     if (!FieldExists($table, 'type_menu')) {
         $migration->addField($table, 'type_menu', "varchar(50) NOT NULL DEFAULT ''");
         $migration->addKey($table, 'type_menu');
         $migration->migrationOneTable($table);
     }
     // Version 0.90-1.1
     $result = $DB->query("SHOW FIELDS FROM `{$table}` where Field ='type_menu'");
     if ($result && $DB->numrows($result)) {
         while ($data = $DB->fetch_assoc($result)) {
             if (stristr($data["Type"], 'varchar') !== FALSE) {
                 $DB->query("ALTER TABLE `{$table}` DROP INDEX `type_menu`;");
                 $DB->query("ALTER TABLE `{$table}` MODIFY `type_menu` text COLLATE utf8_unicode_ci;");
                 $datas = getAllDatasFromTable($table, "`type_menu` IS NOT NULL");
                 if (!empty($datas)) {
                     foreach ($datas as $data) {
                         $itemtypes = PluginTagTagItem::getItemtypes($data['type_menu']);
                         $DB->query("UPDATE `{$table}` SET `type_menu` = '" . json_encode($itemtypes) . "' WHERE `id` = '" . $data['id'] . "'");
                     }
                 }
                 break;
             }
         }
     }
     return true;
 }
开发者ID:korial29,项目名称:tag,代码行数:33,代码来源:tag.class.php


示例19: install

 public static function install(Migration $migration)
 {
     $table = getTableForItemType(__CLASS__);
     if (!TableExists($table)) {
         $migration->displayMessage("Installing {$table}");
         $query = "CREATE TABLE IF NOT EXISTS `{$table}` (\n                     `id` int(11) NOT NULL auto_increment,\n                     `name` varchar(255) NOT NULL DEFAULT '',\n                     `comment` text collate utf8_unicode_ci,\n                     PRIMARY KEY (`id`),\n                     KEY `name` (`name`)\n                  ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci";
         $GLOBALS['DB']->query($query) or die($GLOBALS['DB']->error());
     }
     // Migration from previous version
     if (TableExists('glpi_plugin_formcreator_cats')) {
         $query = "INSERT IGNORE INTO `{$table}` (`id`, `name`)\n                     SELECT `id`,`name` FROM glpi_plugin_formcreator_cats";
         $GLOBALS['DB']->query($query);
         $GLOBALS['DB']->query("DROP TABLE glpi_plugin_formcreator_cats");
     }
     /**
      * Migration of special chars from previous versions
      *
      * @since 0.85-1.2.3
      */
     $query = "SELECT `id`, `name`, `comment`\n                 FROM `{$table}`";
     $result = $GLOBALS['DB']->query($query);
     while ($line = $GLOBALS['DB']->fetch_array($result)) {
         $query_update = 'UPDATE `' . $table . '` SET
                         `name`    = "' . plugin_formcreator_encode($line['name']) . '",
                         `comment` = "' . plugin_formcreator_encode($line['comment']) . '"
                       WHERE `id` = ' . $line['id'];
         $GLOBALS['DB']->query($query_update) or die($GLOBALS['DB']->error());
     }
     return true;
 }
开发者ID:OscarLoayzaB,项目名称:formcreator,代码行数:30,代码来源:category.class.php


示例20: up


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP MimeMagic类代码示例发布时间:2022-05-23
下一篇:
PHP MidasLoader类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap