本文整理汇总了PHP中ActiveRecordModel::executeUpdate方法的典型用法代码示例。如果您正苦于以下问题:PHP ActiveRecordModel::executeUpdate方法的具体用法?PHP ActiveRecordModel::executeUpdate怎么用?PHP ActiveRecordModel::executeUpdate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ActiveRecordModel
的用法示例。
在下文中一共展示了ActiveRecordModel::executeUpdate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
public function setUp()
{
parent::setUp();
ActiveRecordModel::executeUpdate('DELETE FROM ClonedStore');
$this->usd = ActiveRecordModel::getNewInstance('Currency');
$this->usd->setID('ZZZ');
$this->usd->save(ActiveRecord::PERFORM_INSERT);
@unlink(ClonedStoreUpdater::getTimestampFile());
@unlink(ClonedStoreUpdater::getIDFile());
// create stores
for ($k = 0; $k <= 0; $k++) {
$this->stores[$k] = ClonedStore::getNewInstance();
$this->stores[$k]->domain->set($k);
$this->stores[$k]->save();
echo $this->stores[$k]->lastImport->get();
}
// create categories
$root = Category::getRootNode();
for ($k = 0; $k <= 5; $k++) {
$this->categories[] = $this->createCategory($root, $k);
}
$this->categories['1.1'] = $this->createCategory($this->categories[1], '1.1');
$this->categories['1.2'] = $this->createCategory($this->categories[1], '1.2');
$this->categories['1.2.1'] = $this->createCategory($this->categories['1.2'], '1.2.1');
$this->categories['1.2.2'] = $this->createCategory($this->categories['1.2'], '1.2.2');
usleep(1500000);
}
示例2: setUp
public function setUp()
{
parent::setUp();
ActiveRecordModel::executeUpdate('DELETE FROM EavField');
ActiveRecordModel::executeUpdate('DELETE FROM EavObject');
ActiveRecordModel::executeUpdate('DELETE FROM Manufacturer');
}
示例3: deleteByID
public static function deleteByID($className, $id, $foreignKeyName)
{
$inst = ActiveRecordModel::getInstanceById($className, $id, ActiveRecordModel::LOAD_DATA);
$inst->getOwner()->load();
$inst->deleteImageFiles();
// check if main image is being deleted
$owner = $inst->getOwner();
$owner->load(array(get_class($inst)));
if ($owner->defaultImage->get()->getID() == $id) {
// set next image (by position) as the main image
$f = new ARSelectFilter();
$cond = new EqualsCond(new ARFieldHandle(get_class($inst), $foreignKeyName), $owner->getID());
$cond->addAND(new NotEqualsCond(new ARFieldHandle(get_class($inst), 'ID'), $inst->getID()));
$f->setCondition($cond);
$f->setOrder(new ARFieldHandle(get_class($inst), 'position'));
$f->setLimit(1);
$newDefaultImage = ActiveRecordModel::getRecordSet(get_class($inst), $f);
if ($newDefaultImage->size() > 0) {
$owner->defaultImage->set($newDefaultImage->get(0));
$owner->save();
}
}
ActiveRecordModel::executeUpdate('SET FOREIGN_KEY_CHECKS=0');
ActiveRecordModel::executeUpdate('UPDATE ' . $className . ' SET ' . $foreignKeyName . '=NULL , protectedFields="|' . $foreignKeyName . '|" WHERE ID=' . $id);
//return parent::deleteByID($className, $id);
}
示例4: tearDown
public function tearDown()
{
ActiveRecordModel::executeUpdate('DROP TABLE LoadReferenceParent');
ActiveRecordModel::executeUpdate('DROP TABLE LoadReferenceChild');
ActiveRecordModel::executeUpdate('DROP TABLE LoadReferenceSuper');
return parent::tearDown();
}
示例5: setUp
public function setUp()
{
parent::setUp();
$this->controller = new EavFieldController(self::getApplication());
ActiveRecordModel::executeUpdate('DELETE FROM EavField');
ActiveRecordModel::executeUpdate('DELETE FROM EavFieldGroup');
}
示例6: setUp
public function setUp()
{
parent::setUp();
ActiveRecordModel::executeUpdate('DELETE FROM EavField');
$this->controller = new UserController(self::getApplication());
$this->initOrder();
$this->controller->setOrder($this->order);
$this->controller->setUser($this->user);
}
示例7: delete
public function delete()
{
if (ActiveRecordModel::getApplication()->getConfig()->get('CLONE_STORE_TYPE') == 'CLONE_STORE_MASTER') {
return parent::delete();
} else {
ActiveRecordModel::executeUpdate('SET FOREIGN_KEY_CHECKS=0');
ActiveRecordModel::executeUpdate('UPDATE ' . __CLASS__ . ' SET productID=NULL, variationID=NULL, protectedFields="|productID||variationID|" WHERE ID=' . $this->getID());
}
}
示例8: initOrder
protected function initOrder()
{
// set up currency
$this->setUpCurrency();
$this->usd->decimalCount->set(2);
$this->usd->clearRoundingRules();
$this->usd->save();
// initialize order
ActiveRecordModel::executeUpdate('DELETE FROM User WHERE email="test@test.com"');
$user = User::getNewInstance('test@test.com');
$user->save();
$this->user = $user;
$address = UserAddress::getNewInstance();
$address->countryID->set('US');
$state = State::getInstanceById(1, State::LOAD_DATA);
$address->state->set(State::getInstanceById(1));
$address->postalCode->set(90210);
$address->save();
$billing = BillingAddress::getNewInstance($user, $address);
$billing->save();
$address = clone $address;
$address->save();
$shipping = ShippingAddress::getNewInstance($user, $address);
$shipping->save();
$this->order = CustomerOrder::getNewInstance($user);
$this->order->shippingAddress->set($shipping->userAddress->get());
$this->order->billingAddress->set($billing->userAddress->get());
// set up products
$product = Product::getNewInstance(Category::getInstanceById(Category::ROOT_ID), 'test1');
$product->save();
$product->setPrice('USD', 100);
$product->stockCount->set(20);
$product->isEnabled->set(1);
$product->save();
$this->products[] = $product;
$product = Product::getNewInstance(Category::getInstanceById(Category::ROOT_ID), 'test2');
$product->save();
$product->setPrice('USD', 200);
$product->stockCount->set(20);
$product->isEnabled->set(1);
$product->save();
$this->products[] = $product;
$product = Product::getNewInstance(Category::getInstanceById(Category::ROOT_ID), 'test3');
$product->save();
$product->setPrice('USD', 400);
$product->isSeparateShipment->set(true);
$product->stockCount->set(20);
$product->isEnabled->set(1);
$product->save();
$this->products[] = $product;
}
示例9: bulkAddIndex
public static function bulkAddIndex($list)
{
$chunks = array();
while ($item = array_pop($list)) {
$locale = array_key_exists('locale', $item['meta']) ? $item['meta']['locale'] : null;
if ($locale && strlen($locale)) {
$locale = '0x' . bin2hex($locale);
} else {
$locale = 'NULL';
}
$chunks[] = sprintf('(%s, %s, %s, %s, %s)', '0x' . bin2hex($item['value']), $locale, array_key_exists('section', $item) ? '0x' . bin2hex($item['section']) : 'NULL', '0x' . bin2hex(serialize($item['meta'])), array_key_exists('sort', $item) && is_numeric($item['sort']) ? intval($item['sort'], 10) : 'NULL');
}
ActiveRecordModel::executeUpdate('INSERT INTO ' . __CLASS__ . '(value, locale, section, meta, sort) VALUES ' . implode(',', $chunks));
}
示例10: setUp
public function setUp()
{
parent::setUp();
ActiveRecordModel::executeUpdate('DELETE FROM Tax');
ActiveRecordModel::executeUpdate('DELETE FROM TaxRate');
ActiveRecordModel::executeUpdate('DELETE FROM Currency');
ActiveRecordModel::executeUpdate('DELETE FROM DiscountCondition');
ActiveRecordModel::executeUpdate('DELETE FROM DiscountAction');
ActiveRecordModel::executeUpdate('DELETE FROM DeliveryZone');
ActiveRecordModel::executeUpdate('DELETE FROM ShippingService');
BusinessRuleController::clearCache();
$this->initOrder();
$this->config->setRuntime('DELIVERY_TAX', '');
}
示例11: 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();
}
示例12: getIdOffsets
private function getIdOffsets()
{
$file = $this->getOffsetsFile();
if (!file_exists($file)) {
$offsets = array();
$types = $this->getRecordTypes();
unset($types[array_search('Language', $types)]);
unset($types[array_search('ProductRelationship', $types)]);
foreach ($types as $type) {
$f = new ARSelectFilter();
$f->setOrder(new ARFieldHandle($type, 'ID'), 'DESC');
$f->setLimit(1);
$record = array_shift(ActiveRecordModel::getRecordSetArray($type, $f));
if (!$record) {
$record['ID'] = 0;
}
$offsets[$type] = $record['ID'];
try {
ActiveRecordModel::executeUpdate('ALTER TABLE ' . $type . ' AUTO_INCREMENT = ' . ($offsets[$type] + 1));
} catch (Exception $e) {
// we don't care much if it didn't work (won't work with MySQL <5.0.3)
}
}
file_put_contents($file, '<?php return ' . var_export($offsets, true) . '; ?>');
}
return include $file;
}
示例13: tearDown
public function tearDown()
{
ActiveRecordModel::executeUpdate('DROP TABLE SerializedModel');
return parent::tearDown();
}
示例14: testDoubleRatingsByIPWithTimeDifference
public function testDoubleRatingsByIPWithTimeDifference()
{
$_SERVER['REMOTE_ADDR'] = '255.255.255.254';
self::getApplication()->getConfig()->set('RATING_SAME_IP_TIME', 24);
$this->request->set('rating_', 4);
$this->request->set('ajax', 'true');
// first rating
$this->assertRatingError(false);
ActiveRecordModel::executeUpdate('UPDATE ProductRating SET dateCreated="1997-01-01"');
$this->assertRatingError(false);
// vote again - get error
$this->assertRatingError();
// no time difference - vote as much as you want
self::getApplication()->getConfig()->set('RATING_SAME_IP_TIME', 0);
$this->assertRatingError(false);
}
示例15: setUp
public function setUp()
{
parent::setUp();
ActiveRecordModel::executeUpdate('DELETE FROM ProductRatingType');
}