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


PHP ActiveRecord::executeUpdate方法代码示例

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


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

示例1: setUp

 public function setUp()
 {
     parent::setUp();
     ActiveRecord::clearPool();
     ActiveRecord::executeUpdate('DELETE FROM Tax');
     ActiveRecord::executeUpdate('DELETE FROM TaxRate');
     ActiveRecord::executeUpdate('DELETE FROM DeliveryZone');
     ActiveRecord::executeUpdate('DELETE FROM Currency');
     ActiveRecord::executeUpdate('DELETE FROM ShippingService');
     ActiveRecord::executeUpdate('DELETE FROM DeliveryZone');
     ActiveRecord::executeUpdate('DELETE FROM TaxClass');
     $this->deliveryZone = DeliveryZone::getNewInstance();
     $this->deliveryZone->setValueByLang('name', 'en', 'test zone');
     $this->deliveryZone->isEnabled->set(true);
     $this->deliveryZone->save();
     DeliveryZoneCountry::getNewInstance($this->deliveryZone, 'US')->save();
     $this->tax = Tax::getNewInstance('test type');
     $this->tax->save();
     $this->currency = ActiveRecord::getInstanceByIdIfExists('Currency', 'USD');
     $this->currency->isEnabled->set(true);
     $this->currency->decimalCount->set(2);
     $this->currency->save();
     $this->product = Product::getNewInstance(Category::getRootNode());
     $this->product->setPrice('USD', 100);
     $this->product->isEnabled->set(true);
     $this->product->save();
     $this->user = User::getNewInstance('vat.test2@tester.com');
     $this->user->save();
     $this->address = UserAddress::getNewInstance();
     $this->address->countryID->set('US');
     $this->address->save();
     $this->getApplication()->getConfig()->setRuntime('DELIVERY_TAX_CLASS', null);
 }
开发者ID:saiber,项目名称:livecart,代码行数:33,代码来源:TaxRateTest.php

示例2: setUp

 public function setUp()
 {
     parent::setUp();
     BusinessRuleController::clearCache();
     ActiveRecord::executeUpdate('DELETE FROM DeliveryZone');
     ActiveRecord::executeUpdate('DELETE FROM Tax');
     ActiveRecord::executeUpdate('DELETE FROM TaxRate');
     ActiveRecord::executeUpdate('DELETE FROM DiscountCondition');
     ActiveRecord::executeUpdate('DELETE FROM DiscountAction');
     ActiveRecord::executeUpdate('DELETE FROM Currency');
     $this->root = DiscountCondition::getRootNode();
     $this->usd = ActiveRecordModel::getInstanceByIDIfExists('Currency', 'USD');
     $this->usd->save();
     $this->user = User::getNewInstance('discount.condition@test');
     $this->user->save();
     $this->order = CustomerOrder::getNewInstance($this->user);
     $this->order->currency->set($this->usd);
     $this->order->save(true);
     $this->product1 = Product::getNewInstance(Category::getRootNode());
     $this->product1->isEnabled->set(true);
     $this->product1->setPrice('USD', 10);
     $this->product1->save();
     $this->product2 = Product::getNewInstance(Category::getRootNode());
     $this->product2->isEnabled->set(true);
     $this->product2->setPrice('USD', 20);
     $this->product2->save();
     ActiveRecordModel::getApplication()->getConfig()->setRuntime('INVENTORY_TRACKING', 'DISABLE');
 }
开发者ID:saiber,项目名称:livecart,代码行数:28,代码来源:DiscountConditionTest.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: batchIncreaseProcessedRebillCount

    public static function batchIncreaseProcessedRebillCount($ids)
    {
        if (count($ids) == 0) {
            return false;
        }
        ActiveRecord::executeUpdate('UPDATE ' . __CLASS__ . ' SET 
			processedRebillCount = IF(processedRebillCount IS NULL, 1, processedRebillCount+1)
		WHERE
			ID IN(' . implode(',', $ids) . ')');
        //ActiveRecordModel::ClearPool();
        return true;
    }
开发者ID:saiber,项目名称:livecart,代码行数:12,代码来源:RecurringItem.php

示例5: updateSalesRank

 public function updateSalesRank()
 {
     $cacheFile = ClassLoader::getRealPath('cache.salesrank');
     if (!file_exists($cacheFile) || filemtime($cacheFile) < time() - 3600) {
         touch($cacheFile);
         ActiveRecord::executeUpdate('UPDATE Product SET salesRank=(SELECT SUM(count) FROM OrderedItem LEFT JOIN CustomerOrder ON OrderedItem.customerOrderID=CustomerOrder.ID WHERE productID=Product.ID AND CustomerOrder.isPaid=1 AND CustomerOrder.dateCompleted > "' . ARSerializableDateTime::createFromTimeStamp(strtotime('-' . $this->config->get('BESTSELLING_ITEMS_DAYS') . ' days')) . '")');
     }
 }
开发者ID:saiber,项目名称:livecart,代码行数:8,代码来源:Product.php

示例6: getNextCurrency

 public function getNextCurrency()
 {
     if (!$this->currenciesTruncated) {
         ActiveRecord::executeUpdate('DELETE FROM Currency');
         $this->currenciesTruncated = true;
     }
     if (!($data = $this->loadRecord('SELECT * FROM ' . $this->getTablePrefix() . 'currencies'))) {
         return null;
     }
     $curr = ActiveRecordModel::getInstanceByIdIfExists('Currency', $data['code']);
     $curr->pricePrefix->set($data['symbol_left']);
     $curr->priceSuffix->set($data['symbol_right']);
     $curr->rate->set($data['value']);
     $curr->lastUpdated->set($data['last_updated']);
     $curr->isEnabled->set(true);
     if ($this->getConfigValue('DEFAULT_CURRENCY') == $curr->getID()) {
         $curr->isDefault->set(true);
     }
     return $curr;
 }
开发者ID:saiber,项目名称:livecart,代码行数:20,代码来源:OsCommerceImport.php

示例7: loadDatabaseDump

 public function loadDatabaseDump($dump, $flush = false, $force = false)
 {
     // newlines
     $dump = str_replace("\r", '', $dump);
     // clear comments
     $dump = preg_replace('/#.*#/', '', $dump);
     // get queries
     $queries = preg_split('/;\\n/', $dump);
     if ($flush && ob_get_length()) {
         ob_flush();
         ob_end_clean();
     }
     foreach ($queries as $query) {
         $query = trim($query);
         if (!empty($query)) {
             try {
                 ActiveRecord::executeUpdate($query);
             } catch (Exception $e) {
                 if (!$force) {
                     throw $e;
                 }
             }
         }
         if ($flush) {
             echo '.';
             flush();
         }
     }
     return true;
 }
开发者ID:saiber,项目名称:livecart,代码行数:30,代码来源:Installer.php

示例8: removeUnnecessaryCategoriesFromSnapshot

 public function removeUnnecessaryCategoriesFromSnapshot(ClonedStore $store)
 {
     $conds = array();
     foreach ($store->getRelatedRecordSet('ClonedStoreCategory', select(), 'Category') as $storeCat) {
         $cat = $storeCat->category->get();
         if (1 == $cat->getID()) {
             continue;
         }
         $cat->load();
         $cond = lte(f('Category.lft'), $cat->lft->get());
         $cond->addAND(gte(f('Category.rgt'), $cat->rgt->get()));
         $conds[] = $cond;
     }
     $this->flush(__LINE__);
     if (!$conds) {
         return;
     }
     $this->flush(__LINE__);
     $cond = new OrChainCondition($conds);
     $ids = array();
     foreach (ActiveRecordModel::getFieldValues('Category', select($cond), array('ID')) as $id) {
         $ids[] = array_shift($id);
     }
     $idstr = 'IN (' . implode(', ', $ids) . ')';
     // delete unused extra category references
     // ActiveRecord::executeUpdate('DELETE FROM ' . $this->importDatabase . '.ProductCategory WHERE categoryID NOT ' . $idstr);
     $this->flush(__LINE__);
     //var_dump('before: ' . array_shift(array_shift(ActiveRecord::getDataBySQL('SELECT COUNT(*) FROM ' . $this->importDatabase . '.Product'))));
     ActiveRecord::executeUpdate('DELETE FROM ' . $this->importDatabase . '.Product WHERE (categoryID NOT ' . $idstr . ') AND ((SELECT COUNT(*) FROM ' . $this->importDatabase . '.ProductCategory WHERE productID=Product.ID AND (ProductCategory.categoryID ' . $idstr . ')) = 0)');
     //echo 'DELETE FROM ' . $this->importDatabase . '.Product WHERE (categoryID NOT ' . $idstr . ') AND ((SELECT COUNT(*) FROM ' . $this->importDatabase . '.ProductCategory WHERE productID=Product.ID AND (ProductCategory.categoryID ' . $idstr . ')) = 0)';
     //var_dump('AFTER: ' . array_shift(array_shift(ActiveRecord::getDataBySQL('SELECT COUNT(*) FROM ' . $this->importDatabase . '.Product'))));
     //die('test');
     $this->flush(__LINE__);
     // fix main category
     ActiveRecord::executeUpdate('UPDATE ' . $this->importDatabase . '.Product SET categoryID=(SELECT categoryID FROM ' . $this->importDatabase . '.ProductCategory WHERE productID=Product.ID AND ProductCategory.categoryID IN (' . implode(',', $ids) . ') LIMIT 1) WHERE (parentID IS NULL) AND (categoryID NOT ' . $idstr . ')');
     $this->flush(__LINE__);
     // remove redundant extra categories
     ActiveRecord::executeUpdate('DELETE ' . $this->importDatabase . '.ProductCategory FROM ' . $this->importDatabase . '.ProductCategory LEFT JOIN ' . $this->importDatabase . '.Product ON ProductCategory.productID=Product.ID WHERE ProductCategory.categoryID=Product.categoryID');
     $this->flush(__LINE__);
     // delete unused products
     ActiveRecord::executeUpdate('DELETE FROM ' . $this->importDatabase . '.Product WHERE (categoryID IS NULL) AND (parentID IS NULL)');
     $this->flush(__LINE__);
     // get all remaining categories
     $sql = 'SELECT lft, rgt FROM ' . $this->importDatabase . '.Category WHERE ID IN (SELECT categoryID FROM ' . $this->importDatabase . '.ProductCategory)';
     $conds = array();
     foreach (ActiveRecordModel::getDataBySQL($sql) as $row) {
         $cond = lte(f('Category.lft'), $row['lft']);
         $cond->addAND(gte(f('Category.rgt'), $row['rgt']));
         $conds[] = $cond;
     }
     $this->flush(__LINE__);
     $cond = new OrChainCondition($conds);
     $ids = array();
     foreach (ActiveRecordModel::getFieldValues('Category', select($cond), array('ID')) as $id) {
         $ids[] = array_shift($id);
     }
     $this->flush(__LINE__);
     $allidstr = 'IN (' . implode(', ', $ids) . ')';
     // delete unused categories
     ActiveRecord::executeUpdate('DELETE FROM ' . $this->importDatabase . '.Category WHERE (ID<>1) AND (ID NOT ' . $idstr . ') AND (ID NOT ' . $allidstr . ')');
     $this->flush(__LINE__);
     // disable/enable existing products according to category selection
     $store->addQueuedQuery('UPDATE Category SET isEnabled=0 WHERE (ID NOT ' . $idstr . ') AND (ID NOT ' . $allidstr . ')');
     $store->addQueuedQuery('UPDATE Category SET isEnabled=1 WHERE ((ID ' . $idstr . ') OR (ID ' . $allidstr . ')) AND (COALESCE(LOCATE("|isEnabled|", protectedFields), 0) = 0)');
     $this->flush(__LINE__);
     $store->addQueuedQuery('UPDATE Product SET isEnabled=0 WHERE (parentID IS NULL) AND (categoryID NOT ' . $idstr . ') AND (categoryID NOT ' . $allidstr . ')');
     //$store->addQueuedQuery('UPDATE Product SET isEnabled=1 WHERE (parentID IS NULL) AND ((categoryID ' . $idstr . ') OR (categoryID ' . $allidstr . ')) AND (COALESCE(LOCATE("|isEnabled|", protectedFields), 0) = 0)');
     $this->flush(__LINE__);
 }
开发者ID:saiber,项目名称:www,代码行数:69,代码来源:ClonedStoreUpdater.php

示例9: LiveCart

<?php

include '../application/Initialize.php';
ClassLoader::import('application.LiveCart');
new LiveCart();
ClassLoader::import('application.model.product.Product');
ClassLoader::import('application.model.system.Installer');
$file = ClassLoader::getRealPath('installdata.demo') . '.sql';
//$file = 'alter.sql';
if (!file_exists($file)) {
    die('File not found: <strong>' . $file . '</strong>');
}
set_time_limit(0);
Product::getInstanceBySKU('test');
$dump = file_get_contents($file);
// newlines
$dump = str_replace("\r", '', $dump);
// clear comments
$dump = preg_replace('/#.*#/', '', $dump);
// get queries
$queries = preg_split('/;\\n/', $dump);
foreach ($queries as $query) {
    $query = trim($query);
    if (!empty($query)) {
        ActiveRecord::executeUpdate($query);
    }
}
开发者ID:GregerA,项目名称:livecart,代码行数:27,代码来源:ImportDemoDatabase.php

示例10: setUp

 public function setUp()
 {
     parent::setUp();
     ActiveRecord::executeUpdate('DELETE FROM Currency');
     ActiveRecord::executeUpdate('DELETE FROM DiscountCondition');
 }
开发者ID:saiber,项目名称:livecart,代码行数:6,代码来源:CurrencyTest.php


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