本文整理汇总了PHP中Pimcore\Resource::getConnection方法的典型用法代码示例。如果您正苦于以下问题:PHP Resource::getConnection方法的具体用法?PHP Resource::getConnection怎么用?PHP Resource::getConnection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pimcore\Resource
的用法示例。
在下文中一共展示了Resource::getConnection方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getResource
/**
* @return \Zend_Db_Adapter_Abstract
*/
public function getResource()
{
if (!$this->resource) {
// get the \Zend_Db_Adapter_Abstract not the wrapper
$this->resource = Resource::getConnection(true);
}
return $this->resource;
}
示例2: getDb
/**
* @return \Zend_Db_Adapter_Abstract
*/
protected function getDb()
{
if (!$this->db) {
// we're using a new mysql connection here to avoid problems with active (nested) transactions
\Logger::debug("Initialize dedicated MySQL connection for the cache adapter");
$this->db = Resource::getConnection();
}
return $this->db;
}
示例3: getData
/**
* @param OnlineShop_Framework_Pricing_IRule $rule
* @param string $field
*
* @return mixed
*/
private function getData(OnlineShop_Framework_Pricing_IRule $rule, $field)
{
if (!array_key_exists($rule->getId(), self::$cache)) {
$query = <<<'SQL'
SELECT 1
, priceRule.ruleId
, count(priceRule.o_id) as "soldCount"
, sum(orderItem.totalPrice) as "salesAmount"
-- DEBUG INFOS
, orderItem.oo_id as "orderItem"
, `order`.orderdate
FROM object_query_%2$d as `order`
-- ordered products
JOIN object_relations_%2$d as orderItems
ON( 1
AND orderItems.fieldname = "items"
AND orderItems.src_id = `order`.oo_id
)
-- order item
JOIN object_%1$d as orderItem
ON ( 1
AND orderItem.o_id = orderItems.dest_id
)
-- add active price rules
JOIN object_collection_PricingRule_%1$d as priceRule
ON( 1
AND priceRule.o_id = orderItem.oo_id
AND priceRule.fieldname = "PricingRules"
AND priceRule.ruleId = %3$d
)
WHERE 1
AND `order`.orderState = "committed"
LIMIT 1
SQL;
try {
$query = sprintf($query, \Pimcore\Model\Object\OnlineShopOrderItem::classId(), \Pimcore\Model\Object\OnlineShopOrder::classId(), $rule->getId());
$conn = \Pimcore\Resource::getConnection();
self::$cache[$rule->getId()] = $conn->fetchRow($query);
} catch (Exception $e) {
Logger::error($e);
}
}
return self::$cache[$rule->getId()][$field];
}
示例4: getAvailableFilterValues
/**
* get all available values that can bee used for filter
* @param string $field
*
* @return array
* @deprecated refactoring
*/
protected function getAvailableFilterValues($field)
{
if (!$this->availableFilterValues) {
$listing = new self();
$query = $listing->getQuery();
$query = str_replace('-- [GET_AVAILABLE_OPTIONS]', '
, ifnull(GROUP_CONCAT(DISTINCT product.o_id, "|", product.o_parentId SEPARATOR "|"),0) as "available_productId"
, ifnull(GROUP_CONCAT(DISTINCT pricingRule.ruleId SEPARATOR "|"),0) as "available_pricingRules"
', $query);
$query = str_replace('GROUP BY orderItem', '', $query);
$conn = \Pimcore\Resource::getConnection();
$conn->query('SET SESSION group_concat_max_len = 1000000');
$this->availableFilterValues = $conn->fetchRow($query);
}
return explode('|', $this->availableFilterValues['available_' . $field]);
}
示例5: __construct
public function __construct($revision)
{
$this->revision = $revision;
$this->db = \Pimcore\Resource::getConnection();
}
示例6: init
//.........这里部分代码省略.........
} else {
throw new \Zend_Controller_Router_Exception("access denied for " . $this->document->getFullPath());
}
}
// logged in users only
if ($user) {
// set the user to registry so that it is available via \Pimcore\Tool\Admin::getCurrentUser();
\Zend_Registry::set("pimcore_admin_user", $user);
// document editmode
if ($this->getParam("pimcore_editmode")) {
\Zend_Registry::set("pimcore_editmode", true);
// check if there is the document in the session
$docKey = "document_" . $this->getDocument()->getId();
$docSession = Session::getReadOnly("pimcore_documents");
if ($docSession->{$docKey}) {
// if there is a document in the session use it
$this->setDocument($docSession->{$docKey});
} else {
// set the latest available version for editmode if there is no doc in the session
$latestVersion = $this->getDocument()->getLatestVersion();
if ($latestVersion) {
$latestDoc = $latestVersion->loadData();
if ($latestDoc instanceof Document\PageSnippet) {
$this->setDocument($latestDoc);
}
}
}
// register editmode plugin
$front = \Zend_Controller_Front::getInstance();
$front->registerPlugin(new \Pimcore\Controller\Plugin\Frontend\Editmode($this), 1000);
}
// document preview
if ($this->getParam("pimcore_preview")) {
// get document from session
$docKey = "document_" . $this->getParam("document")->getId();
$docSession = Session::getReadOnly("pimcore_documents");
if ($docSession->{$docKey}) {
$this->setDocument($docSession->{$docKey});
}
}
// object preview
if ($this->getParam("pimcore_object_preview")) {
$key = "object_" . $this->getParam("pimcore_object_preview");
$session = Session::getReadOnly("pimcore_objects");
if ($session->{$key}) {
$object = $session->{$key};
// add the object to the registry so every call to Object::getById() will return this object instead of the real one
\Zend_Registry::set("object_" . $object->getId(), $object);
}
}
// for version preview
if ($this->getParam("pimcore_version")) {
// only get version data at the first call || because of embedded Snippets ...
if (!\Zend_Registry::isRegistered("pimcore_version_active")) {
$version = Model\Version::getById($this->getParam("pimcore_version"));
$this->setDocument($version->getData());
\Zend_Registry::set("pimcore_version_active", true);
}
}
}
// for public versions
if ($this->getParam("v")) {
try {
$version = Model\Version::getById($this->getParam("v"));
if ($version->getPublic()) {
$this->setDocument($version->getData());
}
} catch (\Exception $e) {
}
}
// check for persona
if ($this->getDocument() instanceof Document\Page) {
$this->getDocument()->setUsePersona(null);
// reset because of preview and editmode (saved in session)
if ($this->getParam("_ptp") && self::$isInitial) {
$this->getDocument()->setUsePersona($this->getParam("_ptp"));
}
}
// check if document is a wrapped hardlink, if this is the case send a rel=canonical header to the source document
if ($this->getDocument() instanceof Document\Hardlink\Wrapper\WrapperInterface) {
// get the cononical (source) document
$hardlinkCanonicalSourceDocument = Document::getById($this->getDocument()->getId());
$request = $this->getRequest();
if (\Pimcore\Tool\Frontend::isDocumentInCurrentSite($hardlinkCanonicalSourceDocument)) {
$this->getResponse()->setHeader("Link", '<' . $request->getScheme() . "://" . $request->getHttpHost() . $hardlinkCanonicalSourceDocument->getFullPath() . '>; rel="canonical"');
} else {
$id = $hardlinkCanonicalSourceDocument->getId();
$sql = "SELECT dd.key, dd.id, dd.path, ss.mainDomain, CONCAT(ss.mainDomain, SUBSTRING(dd.path, LENGTH(ss.sitePath)+1, LENGTH(dd.path)-LENGTH(ss.sitePath)-1)) relPath FROM documents dd INNER JOIN ( SELECT s.mainDomain, concat(d.path, d.key) sitePath FROM `sites` s INNER JOIN documents d ON s.rootId = d.id ) ss ON dd.path LIKE CONCAT(ss.sitePath, '%') WHERE dd.id={$id};";
$connection = \Pimcore\Resource::getConnection();
$mysqlRequest = $connection->query($sql);
$result = reset($mysqlRequest->fetchAll());
$this->getResponse()->setHeader("Link", '<' . $request->getScheme() . "://" . $result["relPath"] . "/" . $hardlinkCanonicalSourceDocument->getKey() . '>; rel="canonical"');
}
}
}
// set some parameters
$this->editmode = \Zend_Registry::get("pimcore_editmode");
$this->view->editmode = \Zend_Registry::get("pimcore_editmode");
self::$isInitial = false;
}
示例7: load
/**
* @return IOrderListItem[]
*/
public function load()
{
if ($this->list === null) {
// load
$conn = Resource::getConnection();
$this->list = new \ArrayIterator($conn->fetchAll($this->getQuery()));
$this->rowCount = (int) $conn->fetchCol('SELECT FOUND_ROWS() as "cnt"')[0];
}
return $this;
}
示例8: getCurrentAmount
protected function getCurrentAmount(OnlineShop_Framework_Pricing_IRule $rule)
{
if (!array_key_exists($rule->getId(), $this->currentSalesAmount)) {
$query = <<<'SQL'
SELECT 1
, count(priceRule.o_id) as "count"
, sum(orderItem.totalPrice) as "amount"
-- DEBUG INFOS
, orderItem.oo_id as "orderItem"
, `order`.orderdate
FROM object_query_%2$d as `order`
-- ordered products
JOIN object_relations_%2$d as orderItems
ON( 1
AND orderItems.fieldname = "items"
AND orderItems.src_id = `order`.oo_id
)
-- order item
JOIN object_%1$d as orderItem
ON ( 1
AND orderItem.origin__id is null
AND orderItem.o_id = orderItems.dest_id
)
-- add active price rules
JOIN object_collection_PriceRule_%1$d as priceRule
ON( 1
AND priceRule.o_id = orderItem.oo_id
AND priceRule.fieldname = "priceRules"
AND priceRule.ruleId = %3$d
)
WHERE 1
AND `order`.orderState = "committed"
AND `order`.origin__id is null
LIMIT 1
SQL;
$query = sprintf($query, \Pimcore\Model\Object\OnlineShopOrderItem::classId(), \Pimcore\Model\Object\OnlineShopOrder::classId(), $rule->getId());
$conn = \Pimcore\Resource::getConnection();
$this->currentSalesAmount[$rule->getId()] = (int) $conn->fetchRow($query)['amount'];
}
return $this->currentSalesAmount[$rule->getId()];
}