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

PHP ActiveRecordModel类代码示例

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

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



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

示例1: restoreInstance

 public static function restoreInstance($className, ActiveRecordModel $owner, EavFieldCommon $field, $value)
 {
     $specItem = parent::getInstanceByID($className, array(call_user_func(array($className, 'getOwnerIDColumnName')) => $owner->getID(), call_user_func(array($className, 'getFieldIDColumnName')) => $field->getID()));
     $specItem->value->set($value);
     $specItem->resetModifiedStatus();
     return $specItem;
 }
开发者ID:saiber,项目名称:livecart,代码行数:7,代码来源:EavValueSpecificationCommon.php


示例2: save

 protected function save(ActiveRecordModel $listGroup)
 {
     $validator = $this->buildValidator();
     if ($validator->isValid()) {
         $listGroup->loadRequestData($this->request);
         $listGroup->save();
         return new JSONResponse(array('ID' => $listGroup->getID(), 'data' => $listGroup->toArray()), 'success');
     } else {
         return new JSONResponse(array('errors' => $validator->getErrorList()), 'failure');
     }
 }
开发者ID:saiber,项目名称:livecart,代码行数:11,代码来源:ProductListControllerCommon.php


示例3: filter

 public function filter($emptyListIsException = false)
 {
     $request = $this->application->getRequest();
     $parser = $this->getParser();
     $apiFieldNames = $parser->getApiFieldNames();
     $parser->loadDataInRequest($request);
     $f = new ARSelectFilter();
     $id = $request->get('ID');
     if (!empty($id)) {
         $f->mergeCondition(new EqualsCond(new ARFieldHandle('ProductVariation', 'ID'), $id));
     } else {
         throw new Exception('Product variation ID is required');
     }
     $product_variations = ActiveRecordModel::getRecordSetArray('ProductVariation', $f);
     $response = new LiveCartSimpleXMLElement('<response datetime="' . date('c') . '"></response>');
     if ($emptyListIsException && count($product_variations) == 0) {
         throw new Exception('Product variation not found');
     }
     while ($variation = array_shift($product_variations)) {
         $xml = $response->addChild('product_variation');
         foreach ($variation as $k => $v) {
             if (in_array($k, $apiFieldNames)) {
                 $xml->addChild($k, $v);
             }
         }
     }
     return new SimpleXMLResponse($response);
 }
开发者ID:saiber,项目名称:www,代码行数:28,代码来源:ProductVariationApi.php


示例4: setUp

 public function setUp()
 {
     parent::setUp();
     $this->controller = new EavFieldController(self::getApplication());
     ActiveRecordModel::executeUpdate('DELETE FROM EavField');
     ActiveRecordModel::executeUpdate('DELETE FROM EavFieldGroup');
 }
开发者ID:saiber,项目名称:livecart,代码行数:7,代码来源:EavFieldControllerTest.php


示例5: getUrl

 public function getUrl()
 {
     $params = array();
     // user name
     $params['merchant'] = $this->getConfigValue('merchant');
     if ($this->getConfigValue('test')) {
         $params['test'] = 'yes';
     }
     // A seller reference number for a transaction
     $params['orderid'] = $this->details->invoiceID->get();
     $params['uniqueoid'] = $this->details->invoiceID->get();
     // The payment amount
     $params['amount'] = $this->details->amount->get() * 100;
     // The currency code of the payment amount.
     $params['currency'] = $this->getCurrency($this->details->currency->get());
     //$this->notifyUrl = preg_replace('/currency\=[A-Z]{3}/', '', $this->notifyUrl);
     $params['callbackurl'] = $this->notifyUrl;
     $params['accepturl'] = $this->returnUrl;
     $params['cancelurl'] = $this->siteUrl;
     $params['lang'] = ActiveRecordModel::getApplication()->getLocaleCode();
     $params['skiplastpage'] = 1;
     $params['md5key'] = $this->getMd5Key($params);
     $pairs = array();
     foreach ($params as $key => $value) {
         $pairs[] = $key . '=' . urlencode($value);
     }
     return 'https://payment.architrade.com/paymentweb/start.action?' . implode('&', $pairs);
 }
开发者ID:GregerA,项目名称:integry-payments,代码行数:28,代码来源:DibsFlexWin.php


示例6: index

 public function index()
 {
     $this->addIndexBreadCrumb();
     $f = new ARSelectFilter(new EqualsCond(new ARFieldHandle('NewsPost', 'isEnabled'), true));
     $f->setOrder(new ARFieldHandle('NewsPost', 'position'), 'DESC');
     return new ActionResponse('news', ActiveRecordModel::getRecordSetArray('NewsPost', $f));
 }
开发者ID:saiber,项目名称:livecart,代码行数:7,代码来源:NewsController.php


示例7: getInstance

 protected function getInstance($record, CsvImportProfile $profile)
 {
     $fields = $profile->getSortedFields();
     if (isset($fields['ProductReview']['ID'])) {
         $instance = ActiveRecordModel::getInstanceByID('ProductReview', $record[$fields['ProductReview']['ID']], true);
     } else {
         if (isset($fields['Product']['ID'])) {
             $parent = ActiveRecordModel::getInstanceByID('Product', $record[$fields['Product']['ID']], true);
         } else {
             if (isset($fields['Product']['sku'])) {
                 $parent = Product::getInstanceBySku($record[$fields['Product']['sku']]);
             } else {
                 return;
             }
         }
     }
     if (empty($instance) && empty($parent)) {
         return;
     }
     if (empty($instance)) {
         $instance = ProductReview::getNewInstance($parent, User::getNewInstance(''));
         $instance->isEnabled->set(true);
     }
     return $instance;
 }
开发者ID:saiber,项目名称:livecart,代码行数:25,代码来源:ProductReviewImport.php


示例8: filter

 public function filter($emptyListIsException = false)
 {
     $request = $this->application->getRequest();
     $parser = $this->getParser();
     $apiFieldNames = $parser->getApiFieldNames();
     $parser->loadDataInRequest($request);
     $f = new ARSelectFilter();
     $ID = $request->get('ID');
     if (!empty($countryID)) {
         $f->mergeCondition(new EqualsCond(new ARFieldHandle('DeliveryZoneCountry', 'ID'), $ID));
     }
     $countryZones = ActiveRecordModel::getRecordSetArray('DeliveryZoneCountry', $f);
     $response = new LiveCartSimpleXMLElement('<response datetime="' . date('c') . '"></response>');
     if ($emptyListIsException && count($countryZones) == 0) {
         throw new Exception('DeliveryZoneCountry not found');
     }
     while ($country_zone = array_shift($countryZones)) {
         $xmlCountryZone = $response->addChild('delivery_zone_country');
         foreach ($country_zone as $k => $v) {
             if (in_array($k, $apiFieldNames)) {
                 $xmlCountryZone->addChild($k, $v);
             }
         }
     }
     return new SimpleXMLResponse($response);
 }
开发者ID:saiber,项目名称:www,代码行数:26,代码来源:DeliveryZoneCountryApi.php


示例9: index

 public function index()
 {
     // get filter to select manufacturers of active products only
     $rootCat = Category::getRootNode();
     $f = new ARSelectFilter();
     $productFilter = new ProductFilter($rootCat, $f);
     $ids = $counts = array();
     foreach (ActiveRecordModel::getDataBySQL('SELECT DISTINCT(manufacturerID), COUNT(*) AS cnt FROM Product ' . $f->createString() . ' GROUP BY manufacturerID') as $row) {
         $ids[] = $row['manufacturerID'];
         $counts[$row['manufacturerID']] = $row['cnt'];
     }
     $f = new ARSelectFilter(new InCond(new ARFieldHandle('Manufacturer', 'ID'), $ids));
     $f->mergeCondition(new NotEqualsCond(new ARFieldHandle('Manufacturer', 'name'), ''));
     $f->setOrder(new ARFieldHandle('Manufacturer', 'name'));
     $manufacturers = ActiveRecordModel::getRecordSetArray('Manufacturer', $f);
     foreach ($manufacturers as &$manufacturer) {
         $manufacturer['url'] = $this->getManufacturerFilterUrl($manufacturer);
     }
     $this->addBreadCrumb($this->translate('_manufacturers'), '');
     $response = new ActionResponse();
     $response->setReference('manufacturers', $manufacturers);
     $response->set('counts', $counts);
     $response->set('rootCat', $rootCat->toArray());
     return $response;
 }
开发者ID:saiber,项目名称:www,代码行数:25,代码来源:ManufacturersController.php


示例10: reorder

 /**
  * Reorder pages
  *
  * @role sort
  */
 public function reorder()
 {
     $inst = StaticPage::getInstanceById($this->request->get('id'), StaticPage::LOAD_DATA);
     $f = new ARSelectFilter();
     $handle = new ARFieldHandle('StaticPage', 'position');
     if ('down' == $this->request->get('order')) {
         $f->setCondition(new MoreThanCond($handle, $inst->position->get()));
         $f->setOrder($handle, 'ASC');
     } else {
         $f->setCondition(new LessThanCond($handle, $inst->position->get()));
         $f->setOrder($handle, 'DESC');
     }
     $f->setLimit(1);
     $s = ActiveRecordModel::getRecordSet('StaticPage', $f);
     if ($s->size()) {
         $pos = $inst->position->get();
         $replace = $s->get(0);
         $inst->position->set($replace->position->get());
         $replace->position->set($pos);
         $inst->save();
         $replace->save();
         return new JSONResponse(array('id' => $inst->getID(), 'order' => $this->request->get('order')), 'success');
     } else {
         return new JSONResponse(false, 'failure', $this->translate('_could_not_reorder_pages'));
     }
 }
开发者ID:saiber,项目名称:www,代码行数:31,代码来源:StaticPageController.php


示例11: 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);
 }
开发者ID:saiber,项目名称:www,代码行数:27,代码来源:TestStoreCloning.php


示例12: 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('[email protected]');
     $user->save();
     $spec = $user->getSpecification();
     $spec->setAttributeValueByLang($text, 'en', 'text');
     $spec->setAttributeValue($singleSel, $value1);
     $user->save();
     $cloned = clone $user;
     $cloned->email->set('[email protected]');
     $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());
 }
开发者ID:saiber,项目名称:livecart,代码行数:30,代码来源:EavSpecificationManagerTest.php


示例13: getNumber

 public function getNumber()
 {
     $config = ActiveRecordModel::getApplication()->getConfig();
     $startAt = $config->get('SequentialInvoiceNumber_START_AT');
     $prefix = $config->get('SequentialInvoiceNumber_PREFIX');
     $suffix = $config->get('SequentialInvoiceNumber_SUFFIX');
     // get last finalized order
     $last = array_pop(ActiveRecord::getRecordSetArray('CustomerOrder', $this->getSelectFilter()));
     $lastNumber = $last ? $last['invoiceNumber'] : $startAt;
     if (substr($lastNumber, 0, strlen($prefix)) == $prefix) {
         $lastNumber = substr($lastNumber, strlen($prefix));
     }
     if (substr($lastNumber, -1 * strlen($suffix)) == $suffix) {
         $lastNumber = substr($lastNumber, 0, -1 * strlen($suffix));
     }
     preg_match('/[0-9]+/', $lastNumber, $matches);
     $lastNumber = array_shift($matches);
     if ($lastNumber < $startAt) {
         $lastNumber = $startAt;
     }
     // avoid selecting the same order if the invoice number is already taken
     $this->getSelectFilter()->mergeCondition(neq('CustomerOrder.ID', $last['ID']));
     $lastNumber += max($config->get('SequentialInvoiceNumber_STEP'), 1);
     $lastNumber = str_pad($lastNumber, $config->get('SequentialInvoiceNumber_MIN_LENGTH'), '0', STR_PAD_LEFT);
     $lastNumber = $prefix . $lastNumber . $suffix;
     return $lastNumber;
 }
开发者ID:saiber,项目名称:livecart,代码行数:27,代码来源:SequentialInvoiceNumber.php


示例14: getTopCustomers

 public function getTopCustomers()
 {
     $this->setDateHandle(new ARFieldHandle('CustomerOrder', 'dateCompleted'));
     $this->setChartType(self::TABLE);
     $q = $this->getQuery('ROUND(SUM(CustomerOrder.totalAmount * ' . $this->getCurrencyMultiplier() . '), 2)');
     $f = $q->getFilter();
     $f->resetOrder();
     $f->resetGrouping();
     $f->setOrder(new ARExpressionHandle('cnt'), 'DESC');
     $q->addField('userID');
     $f->setGrouping(new ARExpressionHandle('userID'));
     $f->mergeCondition(new EqualsCond(new ARFieldHandle('CustomerOrder', 'isFinalized'), 1));
     $f->mergeCondition(new EqualsCond(new ARFieldHandle('CustomerOrder', 'isCancelled'), 0));
     $f->mergeCondition(new EqualsCond(new ARFieldHandle('CustomerOrder', 'isPaid'), 1));
     $f->setLimit(self::TABLE_LIMIT);
     $q->joinTable('CustomerOrder', 'User', 'userID', 'ID');
     $this->getReportData($q);
     $ids = array();
     foreach ($this->values as $product) {
         $ids[$product['userID']] = $product['cnt'];
     }
     // fetch user details
     $fields = array_flip(array('fullName', 'cnt'));
     foreach (ActiveRecordModel::getRecordSetArray('User', new ARSelectFilter(new INCond(new ARFieldHandle('User', 'ID'), array_keys($ids)))) as $user) {
         $user['cnt'] = $ids[$user['ID']];
         $ids[$user['ID']] = array_merge($fields, array_intersect_key($user, $fields));
     }
     $this->values = $ids;
 }
开发者ID:saiber,项目名称:livecart,代码行数:29,代码来源:CustomerReport.php


示例15: process

 public function process()
 {
     if (!$this->response instanceof ActionResponse) {
         return;
     }
     $products = $this->response->get('products');
     $ids = array();
     foreach ($products as $key => $product) {
         $ids[$product['ID']] = !empty($product['parentID']) ? $product['parentID'] : $product['ID'];
     }
     if (!$ids) {
         return;
     }
     $f = select(in(f('ProductImage.productID'), array_values($ids)), new LikeCond(f('ProductImage.title'), '%Virtual Mirror%'));
     $hasMirror = array();
     foreach (ActiveRecordModel::getRecordSetArray('ProductImage', $f) as $mirror) {
         $hasMirror[$mirror['productID']] = true;
     }
     foreach ($ids as $realID => $parentID) {
         if (!empty($hasMirror[$parentID])) {
             $hasMirror[$realID] = true;
         }
     }
     foreach ($products as $key => $product) {
         if ($hasMirror[$product['ID']]) {
             $products[$key]['hasMirror'] = true;
         }
     }
     $this->response->set('hasMirror', $hasMirror);
     $this->response->set('products', $products);
 }
开发者ID:saiber,项目名称:www,代码行数:31,代码来源:LoadMirror.php


示例16: getLanguageIDs

 private function getLanguageIDs()
 {
     if (!$this->langIDs) {
         $this->langIDs = ActiveRecordModel::getApplication()->getLanguageArray(true);
     }
     return $this->langIDs;
 }
开发者ID:saiber,项目名称:livecart,代码行数:7,代码来源:LiveCartRouter.php


示例17: 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);
 }
开发者ID:saiber,项目名称:www,代码行数:26,代码来源:ObjectImage.php


示例18: testSimpleImport

 public function testSimpleImport()
 {
     $lv = ActiveRecordModel::getNewInstance('Language');
     $lv->setID('xx');
     $lv->save();
     $profile = new CsvImportProfile('Product');
     $profile->setField(0, 'Product.sku');
     $profile->setField(1, 'Product.name', array('language' => 'en'));
     $profile->setField(2, 'Product.name', array('language' => 'xx'));
     $profile->setField(3, 'Product.shippingWeight');
     $profile->setParam('delimiter', ';');
     $csvFile = ClassLoader::getRealPath('cache.') . 'testDataImport.csv';
     file_put_contents($csvFile, 'test; "Test Product"; "Parbaudes Produkts"; 15' . "\n" . 'another; "Another Test"; "Vel Viens"; 12.44');
     $import = new ProductImport($this->getApplication());
     $csv = $profile->getCsvFile($csvFile);
     $cnt = $import->importFile($csv, $profile);
     $this->assertEquals($cnt, 2);
     $test = Product::getInstanceBySKU('test');
     $this->assertTrue($test instanceof Product);
     $this->assertEquals($test->shippingWeight->get(), '15');
     $this->assertEquals($test->getValueByLang('name', 'en'), 'Test Product');
     $another = Product::getInstanceBySKU('another');
     $this->assertEquals($another->getValueByLang('name', 'xx'), 'Vel Viens');
     unlink($csvFile);
 }
开发者ID:saiber,项目名称:livecart,代码行数:25,代码来源:ProductImportTest.php


示例19: getSelectFilter

 public function getSelectFilter($disableFilters = false)
 {
     $selectFilter = $this->category->getProductsFilter($this, false);
     $selectFilter->merge($this->productFilter);
     $cond = null;
     if ($disableFilters == false) {
         $list = array();
         // group filters by class
         foreach ($this->filters as $filter) {
             $id = $filter instanceof SpecificationFilterInterface ? $filter->getFilterGroup()->getID() : '';
             $list[get_class($filter) . '_' . $id][] = $filter->getCondition();
             $filter->defineJoin($selectFilter);
         }
         // convert filter group to OrChainCondition
         foreach ($list as &$filterGroup) {
             $filterGroup = new OrChainCondition($filterGroup);
         }
         if ($fCond = $selectFilter->getCondition()) {
             $list[] = $fCond;
         }
         $selectFilter->setCondition(new AndChainCondition($list));
         // all merged with and
     }
     ActiveRecordModel::getApplication()->processInstancePlugins('finalProductFilter', $selectFilter);
     return $selectFilter;
 }
开发者ID:GregerA,项目名称:livecart,代码行数:26,代码来源:ProductFilter.php


示例20: filter

 public function filter($emptyListIsException = false)
 {
     $request = $this->application->getRequest();
     $parser = $this->getParser();
     $apiFieldNames = $parser->getApiFieldNames();
     $parser->loadDataInRequest($request);
     $f = new ARSelectFilter();
     $id = $request->get('ID');
     if (intval($id) > 0) {
         $f->mergeCondition(new EqualsCond(new ARFieldHandle('NewsPost', 'ID'), $id));
     }
     $f->setOrder(new ARExpressionHandle('NewsPost.ID'), 'DESC');
     $newspost = ActiveRecordModel::getRecordSetArray('NewsPost', $f);
     $response = new LiveCartSimpleXMLElement('<response datetime="' . date('c') . '"></response>');
     if ($emptyListIsException && count($newspost) == 0) {
         throw new Exception('News post not found');
     }
     while ($category = array_shift($newspost)) {
         $xmlNewsPost = $response->addChild('newspost');
         foreach ($category as $k => $v) {
             if (in_array($k, $apiFieldNames)) {
                 $xmlNewsPost->addChild($k, htmlentities($v));
             }
         }
     }
     return new SimpleXMLResponse($response);
 }
开发者ID:saiber,项目名称:www,代码行数:27,代码来源:NewsPostApi.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP ActivitiResponseObject类代码示例发布时间:2022-05-23
下一篇:
PHP ActiveRecord类代码示例发布时间: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