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


PHP oxDb::getdb方法代码示例

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


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

示例1: testGetSqlActiveSnippetIfParentWillBeLoadedOnSpecialItsVariantsSetup

 /**
  * Test get sql active snippet if parent will be loaded on special its variants setup.
  *
  * @return null
  */
 public function testGetSqlActiveSnippetIfParentWillBeLoadedOnSpecialItsVariantsSetup()
 {
     $sArticleId = '_testArticleId';
     $sShopId = $this->getConfig()->getShopId();
     $oArticle = oxNew('oxArticle');
     $sTable = $oArticle->getViewName();
     $oDb = oxDb::getdb();
     $this->getConfig()->setConfigParam("blUseTimeCheck", 0);
     $this->getConfig()->setConfigParam("blUseStock", 0);
     $this->getConfig()->setConfigParam("blVariantParentBuyable", 0);
     // just some inactive article
     $oArticle = oxNew('oxArticle');
     $oArticle->setId($sArticleId);
     $oArticle->oxarticles__oxshopid = new oxField($sShopId);
     $oArticle->oxarticles__oxactive = new oxField(0);
     $oArticle->save();
     $sQ = "select 1 from ({$sTable}) where oxid='{$sArticleId}' and " . $oArticle->getSqlActiveSnippet();
     $this->assertFalse($oDb->getOne($sQ));
     // regular active product
     $oArticle->oxarticles__oxactive = new oxField(1);
     $oArticle->save();
     $sQ = "select 1 from ({$sTable}) where oxid='{$sArticleId}' and " . $oArticle->getSqlActiveSnippet();
     $this->assertEquals("1", $oDb->getOne($sQ));
     $this->getConfig()->setConfigParam("blUseTimeCheck", 1);
     $this->getConfig()->setConfigParam("blUseStock", 0);
     $this->getConfig()->setConfigParam("blVariantParentBuyable", 0);
     $iCurrTime = oxRegistry::get("oxUtilsDate")->getTime();
     // regular active product by time range
     $oArticle->oxarticles__oxactive = new oxField(0);
     $oArticle->oxarticles__oxactivefrom = new oxField(date('Y-m-d H:i:s', $iCurrTime - 3600));
     $oArticle->oxarticles__oxactiveto = new oxField(date('Y-m-d H:i:s', $iCurrTime + 3600));
     $oArticle->save();
     $sQ = "select 1 from ({$sTable}) where oxid='{$sArticleId}' and " . $oArticle->getSqlActiveSnippet();
     $this->assertEquals("1", $oDb->getOne($sQ));
     // stock check is on
     $this->getConfig()->setConfigParam("blUseTimeCheck", 1);
     $this->getConfig()->setConfigParam("blUseStock", 1);
     $this->getConfig()->setConfigParam("blVariantParentBuyable", 0);
     // stock = 0, stock flag = 2
     $oArticle->oxarticles__oxstock = new oxField(0);
     $oArticle->oxarticles__oxstockflag = new oxField(2);
     $oArticle->save();
     $sQ = "select 1 from ({$sTable}) where oxid='{$sArticleId}' and " . $oArticle->getSqlActiveSnippet();
     $this->assertFalse($oDb->getOne($sQ));
     // stock > 0, stock flag = 2
     $oArticle->oxarticles__oxstock = new oxField(1);
     $oArticle->oxarticles__oxstockflag = new oxField(2);
     $oArticle->save();
     $sQ = "select 1 from ({$sTable}) where oxid='{$sArticleId}' and " . $oArticle->getSqlActiveSnippet();
     $this->assertEquals("1", $oDb->getOne($sQ));
     // has 2 active variants, but parent itself is not buyable
     $oVar1 = oxNew('oxArticle');
     $oVar1->setId('_testVariant1');
     $oVar1->oxarticles__oxshopid = new oxField($sShopId);
     $oVar1->oxarticles__oxactive = new oxField(1);
     $oVar1->oxarticles__oxstock = new oxField(1);
     $oVar1->oxarticles__oxparentid = new oxField($oArticle->getId());
     $oVar1->save();
     $oVar2 = oxNew('oxArticle');
     $oVar2->setId('_testVariant2');
     $oVar2->oxarticles__oxshopid = new oxField($sShopId);
     $oVar2->oxarticles__oxactive = new oxField(1);
     $oVar2->oxarticles__oxstock = new oxField(1);
     $oVar2->oxarticles__oxparentid = new oxField($oArticle->getId());
     $oVar2->save();
     $sQ = "select 1 from ({$sTable}) where oxid='{$sArticleId}' and " . $oArticle->getSqlActiveSnippet();
     $this->assertEquals("1", $oDb->getOne($sQ));
     // has no active variants (2 inactive)
     $oVar1->oxarticles__oxactive = new oxField(0);
     $oVar1->save();
     $oVar2->oxarticles__oxactive = new oxField(0);
     $oVar2->save();
     $sQ = "select 1 from ({$sTable}) where oxid='{$sArticleId}' and " . $oArticle->getSqlActiveSnippet();
     $this->assertFalse($oDb->getOne($sQ));
     // has 2 active variants and parent itself is buyable
     $this->getConfig()->setConfigParam("blUseTimeCheck", 1);
     $this->getConfig()->setConfigParam("blUseStock", 1);
     $this->getConfig()->setConfigParam("blVariantParentBuyable", 1);
     $oVar1->oxarticles__oxactive = new oxField(1);
     $oVar1->save();
     $oVar2->oxarticles__oxactive = new oxField(1);
     $oVar2->save();
     $sQ = "select 1 from ({$sTable}) where oxid='{$sArticleId}' and " . $oArticle->getSqlActiveSnippet();
     $this->assertEquals("1", $oDb->getOne($sQ));
     // has no active variants and parent itself is buyable
     $oVar1->oxarticles__oxactive = new oxField(0);
     $oVar1->save();
     $oVar2->oxarticles__oxactive = new oxField(0);
     $oVar2->save();
     $sQ = "select 1 from ({$sTable}) where oxid='{$sArticleId}' and " . $oArticle->getSqlActiveSnippet();
     $this->assertEquals("1", $oDb->getOne($sQ));
 }
开发者ID:Crease29,项目名称:oxideshop_ce,代码行数:97,代码来源:oxarticleTest.php


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