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


PHP Installer::loadDatabaseDump方法代码示例

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


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

示例1: update

 /**
  *  Handles LiveCart update process
  */
 public function update()
 {
     $dir = ClassLoader::getRealPath('update') . '/' . $this->getCurrentVersion();
     if (!is_dir($dir)) {
         return new RawResponse('Update directory not found');
     }
     $progress = array();
     $errors = array();
     // load SQL dump file
     $sql = $dir . '/update.sql';
     if (file_exists($sql)) {
         try {
             Installer::loadDatabaseDump(file_get_contents($sql), true, $this->request->get('force'));
             $progress['sql'] = true;
         } catch (Exception $e) {
             $errors['sql'] = $e->getMessage();
         }
     }
     $this->application->getConfigContainer()->clearCache();
     // execute custom update code
     $code = $dir . '/custom.php';
     if (file_exists($code)) {
         ob_start();
         if (!(include $code)) {
             $errors['code'] = ob_get_contents();
         } else {
             $progress['code'] = true;
         }
         ob_end_clean();
     }
     $response = new ActionResponse();
     $response->set('progress', $progress);
     $response->set('errors', $errors);
     return $response;
 }
开发者ID:saiber,项目名称:www,代码行数:38,代码来源:UpdateController.php

示例2: import

 public function import()
 {
     $this->application->setDevMode(true);
     ignore_user_abort(true);
     ini_set('memory_limit', '512M');
     set_time_limit(0);
     if ($this->request->get('password') != $this->config->get('CLONE_STORE_API_KEY')) {
         return new RawResponse('Wrong password');
     }
     ActiveRecordModel::executeUpdate('SET FOREIGN_KEY_CHECKS=0;');
     ActiveRecord::getLogger()->setLogFileName(null);
     $dir = $this->getFileDir();
     //if (ob_get_length())
     //{
     ob_flush();
     ob_end_clean();
     //}
     //echo str_repeat('FLUSH ', 10000);
     foreach (scandir($dir) as $file) {
         if (strlen($file) < 3) {
             continue;
         }
         $path = $dir . $file;
         if (substr($file, -4) == '.sql') {
             $f = fopen($path, 'r');
             $prev = '';
             while (!feof($f)) {
                 $s = $prev . fread($f, 1024 * 1024);
                 if (!feof($f)) {
                     $pos = strrpos($s, ";\n");
                     $prev = substr($s, $pos + 1);
                     $s = substr($s, 0, $pos);
                 }
                 Installer::loadDatabaseDump($s, true);
             }
         } else {
             $this->untar($path, ClassLoader::getRealPath('public.upload.'));
         }
         unlink($path);
     }
     $this->user->allowBackendAccess();
     $c = new ProductImageController($this->application);
     $c->resizeImages();
     Category::reindex();
     Category::recalculateProductsCount();
 }
开发者ID:saiber,项目名称:www,代码行数:46,代码来源:StoreSyncController.php

示例3: setDatabase

 public function setDatabase()
 {
     set_time_limit(0);
     if (!$this->buildDatabaseValidator()->isValid()) {
         return new ActionRedirectResponse('install', 'database');
     }
     $type = function_exists('mysql_connect') ? 'mysql' : 'mysqli';
     $dsn = $type . '://' . $this->request->get('username') . ($this->request->get('password') ? ':' . $this->request->get('password') : '') . '@' . $this->request->get('server') . '/' . $this->request->get('name');
     ClassLoader::import('library.activerecord.ActiveRecord');
     ActiveRecord::resetDBConnection();
     ActiveRecord::setDSN($dsn);
     try {
         $conn = ActiveRecord::getDBConnection();
         // test if InnoDB tables can be created
         $table = 'TestInnoDB';
         $create = 'CREATE TABLE ' . $table . ' (ID INTEGER) ENGINE = INNODB';
         $drop = 'DROP TABLE ' . $table;
         ActiveRecord::executeUpdate($create);
         $data = ActiveRecord::getDataBySQL('SHOW TABLE STATUS');
         ActiveRecord::executeUpdate($drop);
         foreach ($data as $row) {
             if (strtolower($row['Name']) == strtolower($table)) {
                 if (strtolower($row['Engine']) != 'innodb') {
                     throw new SQLException('', $this->translate('_err_innodb_not_available'));
                 }
             }
         }
         $dsnFile = $this->getDsnFile();
         if (!file_exists(dirname($dsnFile))) {
             mkdir(dirname($dsnFile), 0777, true);
         }
         ActiveRecord::beginTransaction();
         //ActiveRecord::executeUpdate('SET FOREIGN_KEY_CHECKS = 0');
         //ActiveRecord::executeUpdate('DROP TABLE `AccessControlAssociation`, `AdAdvertiser`, `AdAdvertiserUser`, `AdBanner`, `AdBannerStats`, `AdCampaign`, `AdCampaignCondition`, `AdZone`, `Author`, `AuthorImage`, `BillingAddress`, `Category`, `CategoryImage`, `CategoryPresentation`, `CategorySubscribeCategory`, `CategorySubscribeQueue`, `CategorySubscribeUser`, `Currency`, `CustomerOrder`, `DeliveryZone`, `DeliveryZoneAddressMask`, `DeliveryZoneCityMask`, `DeliveryZoneCountry`, `DeliveryZoneRealTimeService`, `DeliveryZoneState`, `DeliveryZoneWarehouse`, `DeliveryZoneZipMask`, `Discount`, `DiscountAction`, `DiscountCondition`, `DiscountConditionRecord`, `EavDateValue`, `EavField`, `EavFieldGroup`, `EavItem`, `EavNumericValue`, `EavObject`, `EavStringValue`, `EavValue`, `ExpressCheckout`, `Filter`, `FilterGroup`, `HelpComment`, `Language`, `Manufacturer`, `ManufacturerImage`, `NewsletterMessage`, `NewsletterSentMessage`, `NewsletterSubscriber`, `NewsPost`, `OrderCoupon`, `OrderDiscount`, `OrderedItem`, `OrderedItemOption`, `OrderLog`, `OrderNote`, `PostalCode`, `Product`, `ProductBundle`, `ProductCategory`, `ProductFile`, `ProductFileGroup`, `ProductImage`, `ProductList`, `ProductListItem`, `ProductOption`, `ProductOptionChoice`, `ProductPrice`, `ProductRating`, `ProductRatingSummary`, `ProductRatingType`, `ProductRelationship`, `ProductRelationshipGroup`, `ProductReview`, `ProductVariation`, `ProductVariationTemplate`, `ProductVariationType`, `ProductVariationValue`, `ProductWarehouse`, `PurchasePointsItemOrder`, `PurchasePointsOrder`, `PurchasePointsUser`, `RecurringProductPeriod`, `RewardPointsOrder`, `RewardPointsUser`, `Role`, `SearchLog`, `SessionData`, `Shipment`, `ShipmentTax`, `ShipmentWarehouse`, `ShippingAddress`, `ShippingRate`, `ShippingService`, `SpecField`, `SpecFieldGroup`, `SpecFieldValue`, `SpecificationDateValue`, `SpecificationItem`, `SpecificationNumericValue`, `SpecificationStringValue`, `State`, `StaticPage`, `Tax`, `TaxRate`, `Transaction`, `User`, `UserAddress`, `UserGroup`, `Warehouse`');
         // import schema
         Installer::loadDatabaseDump(file_get_contents(ClassLoader::getRealPath('installdata.sql') . '/create.sql'), true);
         // create root category
         Installer::loadDatabaseDump(file_get_contents(ClassLoader::getRealPath('installdata.sql') . '/initialData.sql'), true);
         // states
         Installer::loadDatabaseDump(file_get_contents(ClassLoader::getRealPath('installdata.sql.state') . '/all.sql'), true);
         file_put_contents($dsnFile, '<?php return ' . var_export($dsn, true) . '; ?>');
         ActiveRecord::commit();
         return new ActionResponse();
         //return new ActionRedirectResponse('install', 'admin');
     } catch (SQLException $e) {
         $validator = $this->buildDatabaseValidator();
         $validator->triggerError('connect', $e->getNativeError());
         $validator->saveState();
         return new ActionResponse('step', 'database');
         //return new ActionRedirectResponse('install', 'database');
     }
 }
开发者ID:GregerA,项目名称:livecart,代码行数:52,代码来源:InstallController.php

示例4: loadSQL

 protected function loadSQL($file)
 {
     ClassLoader::import('application.model.system.Installer');
     if (file_exists($file)) {
         return Installer::loadDatabaseDump(file_get_contents($file));
     } else {
         return true;
     }
 }
开发者ID:saiber,项目名称:www,代码行数:9,代码来源:ConfigurationContainer.php


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