本文整理汇总了PHP中ActiveRecordModel::clearPool方法的典型用法代码示例。如果您正苦于以下问题:PHP ActiveRecordModel::clearPool方法的具体用法?PHP ActiveRecordModel::clearPool怎么用?PHP ActiveRecordModel::clearPool使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ActiveRecordModel
的用法示例。
在下文中一共展示了ActiveRecordModel::clearPool方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testClone
public function testClone()
{
$text = EavField::getNewInstance('User', EavField::DATATYPE_TEXT, EavField::TYPE_TEXT_SIMPLE);
$text->save();
$singleSel = EavField::getNewInstance('User', EavField::DATATYPE_NUMBERS, EavField::TYPE_NUMBERS_SELECTOR);
$singleSel->handle->set('single.sel');
$singleSel->setValueByLang('name', 'en', 'Select one value');
$singleSel->save();
$value1 = EavValue::getNewInstance($singleSel);
$value1->setValueByLang('value', 'en', $firstValue = '20');
$value1->save();
$value2 = EavValue::getNewInstance($singleSel);
$value2->setValueByLang('value', 'en', $secValue = '30');
$value2->save();
$user = User::getNewInstance('someuser@eavclonetest.com');
$user->save();
$spec = $user->getSpecification();
$spec->setAttributeValueByLang($text, 'en', 'text');
$spec->setAttributeValue($singleSel, $value1);
$user->save();
$cloned = clone $user;
$cloned->email->set('cloneduser@test.com');
$cloned->save();
$this->assertNotSame($cloned->getSpecification(), $user->getSpecification());
$this->assertEquals($cloned->getSpecification()->getAttribute($text)->getValueByLang('value', 'en'), 'text');
ActiveRecordModel::clearPool();
$reloaded = ActiveRecordModel::getInstanceByID('User', $cloned->getID(), true);
$this->assertEquals($reloaded->getSpecification()->getAttribute($text)->getValueByLang('value', 'en'), 'text');
$this->assertEquals($reloaded->getSpecification()->getAttribute($singleSel)->getValue()->get()->getID(), $value1->getID());
}
示例2: testEavQueue
public function testEavQueue()
{
// set up Manufacturer records
$field = EavField::getNewInstance('Manufacturer', EavField::DATATYPE_TEXT, EavField::TYPE_TEXT_SIMPLE);
$field->save();
$data = array('first', 'second', 'third');
foreach ($data as $value) {
$manufacturer = Manufacturer::getNewInstance($value);
$manufacturer->getSpecification()->setAttributeValueByLang($field, 'en', $value . ' test');
$manufacturer->save();
}
ActiveRecordModel::clearPool();
// fetch them from database
$manufacturers = ActiveRecordModel::getRecordSetArray('Manufacturer', new ARSelectFilter());
foreach ($manufacturers as &$entry) {
ActiveRecordModel::addToEavQueue('Manufacturer', $entry);
}
// duplicate
$manufacturers = array_merge($manufacturers, $manufacturers);
// load EAV data
ActiveRecordModel::loadEav();
foreach ($manufacturers as $man) {
$this->assertEqual($man['name'] . ' test', $man['attributes'][$field->getID()]['value_en']);
}
}
示例3: testPreferences
public function testPreferences()
{
$user = User::getNewInstance('_tester@tester.com', 'tester', $this->group);
$user->setPreference('test', 'value');
$user->save();
$this->assertEqual($user->getPreference('test'), 'value');
// update preferences
$user->setPreference('another', 'check');
$user->save();
ActiveRecordModel::clearPool();
$reloaded = User::getInstanceByID($user->getID(), true);
$this->assertNotSame($user, $reloaded);
$this->assertEqual($reloaded->getPreference('test'), 'value');
$this->assertEqual($reloaded->getPreference('another'), 'check');
}
示例4: _testStringSerialize
private function _testStringSerialize($string, $equals = true)
{
error_reporting(E_WARNING);
$root = Category::getInstanceByID(1);
$new = Category::getNewInstance($root);
$new->setValueByLang('name', 'en', $string);
$new->save();
ActiveRecordModel::clearPool();
$restored = Category::getInstanceByID($new->getID(), Category::LOAD_DATA);
if ($equals) {
$this->assertEqual($string, $restored->getValueByLang('name', 'en'));
} else {
$this->assertNotEquals($string, $restored->getValueByLang('name', 'en'));
}
error_reporting(E_ALL);
}
示例5: testLoadAllReferencesIncludingAutoLoad
public function testLoadAllReferencesIncludingAutoLoad()
{
$child = ActiveRecordModel::getNewInstance('LoadReferenceChild');
$child->name->set('child');
$child->setID(4);
$child->save();
$parent = ActiveRecordModel::getNewInstance('LoadReferenceParent');
$parent->setID(4);
$parent->name->set('parent');
$parent->reference->set($child);
$parent->save();
$super = ActiveRecordModel::getNewInstance('LoadReferenceSuper');
$super->setID(1);
$super->name->set('super');
$super->reference->set($parent);
$super->save();
$schema = ActiveRecordModel::getSchemaInstance('LoadReferenceParent');
$schema->registerAutoReference('referenceID');
ActiveRecordModel::clearPool();
$newSuper = ActiveRecordModel::getInstanceByID('LoadReferenceSuper', 1, ActiveRecordModel::LOAD_DATA, true);
$this->assertNotSame($child, $newSuper->reference->get()->reference->get());
$this->assertNotSame($newSuper->reference->get(), $newSuper->reference->get()->reference->get());
$this->assertEqual('child', $newSuper->reference->get()->reference->get()->name->get());
}
示例6: testClone
public function testClone()
{
$image = ActiveRecordModel::getNewInstance('ProductImage');
$image->product->set($this->product);
$image->save();
$this->assertSame($image, $this->product->defaultImage->get());
$numField = SpecField::getNewInstance($this->productCategory, SpecField::DATATYPE_NUMBERS, SpecField::TYPE_NUMBERS_SIMPLE);
$numField->save();
$this->product->setAttributeValue($numField, 100);
$this->product->save();
$option = ProductOption::getNewInstance($this->product);
$option->type->set(ProductOption::TYPE_SELECT);
$option->setValueByLang('name', 'en', 'test');
$option->save();
$related = Product::getNewInstance($this->productCategory, 'related');
$related->save();
$relGroup = ProductRelationshipGroup::getNewInstance($this->product, ProductRelationship::TYPE_CROSS);
$relGroup->save();
$rel = ProductRelationship::getNewInstance($this->product, $related, $relGroup);
$rel->save();
$this->assertEquals(1, $this->product->getRelationships()->size());
$cloned = clone $this->product;
$this->assertEquals(100, $cloned->getSpecification()->getAttribute($numField)->value->get());
$cloned->setAttributeValue($numField, 200);
$cloned->setPrice($this->usd, 80);
$cloned->save();
$this->assertNotEquals($cloned->getID(), $this->product->getID());
ActiveRecordModel::clearPool();
$reloaded = Product::getInstanceByID($cloned->getID(), true);
$reloaded->loadPricing();
$this->assertEquals(80, $reloaded->getPrice($this->usd));
$reloaded->loadSpecification();
$this->assertEquals(200, $reloaded->getSpecification()->getAttribute($numField)->value->get());
// related products
$rel = $reloaded->getRelationships();
$this->assertEquals(1, $rel->size());
$this->assertSame($reloaded, $rel->get(0)->productRelationshipGroup->get()->product->get());
// options
$clonedOpts = ProductOption::getProductOptions($reloaded);
$this->assertEquals(1, $clonedOpts->size());
// image
$this->assertTrue(is_object($reloaded->defaultImage->get()));
$this->assertNotEquals($reloaded->defaultImage->get()->getID(), $this->product->defaultImage->get()->getID());
}
示例7: testReloadedVariationPricing
public function testReloadedVariationPricing()
{
$variation = $this->products[0]->createChildProduct();
$variation->isEnabled->set(true);
$variation->setChildSetting('price', Product::CHILD_OVERRIDE);
$variation->setPrice('USD', 0);
$variation->save();
// clear pool and reload only variation instance
ActiveRecordModel::clearPool();
$reloadedVar = Product::getInstanceByID($variation->getID(), true);
$order = CustomerOrder::getNewInstance($this->user);
$order->addProduct($reloadedVar, 1, true);
$this->assertEquals($order->getTotal(true), 100);
}
示例8: set_OrderedItem_products
protected function set_OrderedItem_products($instance, $value, $record, CsvImportProfile $profile)
{
if (!$value) {
return;
}
$productProfile = new CsvImportProfile('OrderedItem');
$productProfile->setField(0, 'OrderedItem.sku');
$productProfile->setField(1, 'OrderedItem.count');
$productProfile->setField(2, 'OrderedItem.price');
$productProfile->setField(3, 'OrderedItem.shipment');
foreach (explode(';', $value) as $product) {
$item = explode(':', $product);
$this->set_OrderedItem_sku($instance, $item[0], $item, $productProfile);
}
ActiveRecordModel::clearPool();
$instance = CustomerOrder::getInstanceByID($instance->getID());
$instance->loadAll();
$instance->isFinalized->set(false);
$instance->finalize(array('customPrice' => true, 'allowRefinalize' => true));
$instance->save();
}
示例9: testRecursiveAutoReference
public function testRecursiveAutoReference()
{
$child = ActiveRecordModel::getNewInstance('AutoReferenceChild');
$child->name->set('child');
$child->save();
$parent = ActiveRecordModel::getNewInstance('AutoReferenceParent');
$parent->setID(4);
$parent->name->set('parent');
$parent->reference->set($child);
$parent->save();
$parent->setID(4);
$parent->reload();
$super = ActiveRecordModel::getNewInstance('AutoReferenceSuper');
$super->setID(1);
$super->name->set('super');
$super->reference->set($parent);
$super->save();
ActiveRecordModel::clearPool();
$newSuper = ActiveRecordModel::getInstanceByID('AutoReferenceSuper', 1, ActiveRecordModel::LOAD_DATA);
//print_R($newSuper->toArray());
$this->assertNotSame($child, $newSuper->reference->get()->reference->get());
$this->assertNotSame($newSuper->reference->get(), $newSuper->reference->get()->reference->get());
$this->assertEqual('child', $newSuper->reference->get()->reference->get()->name->get());
}