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


PHP Db::get方法代码示例

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


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

示例1: showAction

 public function showAction()
 {
     $offset = $this->getParam("start");
     $limit = $this->getParam("limit");
     $orderby = "ORDER BY id DESC";
     $sortingSettings = \Pimcore\Admin\Helper\QueryParams::extractSortingSettings($this->getAllParams());
     if ($sortingSettings['orderKey']) {
         $orderby = "ORDER BY " . $sortingSettings['orderKey'] . " " . $sortingSettings['order'];
     }
     $queryString = " WHERE 1=1";
     if ($this->getParam("priority") != "-1" && ($this->getParam("priority") == "0" || $this->getParam("priority"))) {
         $levels = [];
         foreach (["emergency", "alert", "critical", "error", "warning", "notice", "info", "debug"] as $level) {
             $levels[] = "priority = '" . $level . "'";
             if ($this->getParam("priority") == $level) {
                 break;
             }
         }
         $queryString .= " AND (" . implode(" OR ", $levels) . ")";
     }
     if ($this->getParam("fromDate")) {
         $datetime = $this->getParam("fromDate");
         if ($this->getParam("fromTime")) {
             $datetime = substr($datetime, 0, 11) . $this->getParam("fromTime") . ":00";
         }
         $queryString .= " AND timestamp >= '" . $datetime . "'";
     }
     if ($this->getParam("toDate")) {
         $datetime = $this->getParam("toDate");
         if ($this->getParam("toTime")) {
             $datetime = substr($datetime, 0, 11) . $this->getParam("toTime") . ":00";
         }
         $queryString .= " AND timestamp <= '" . $datetime . "'";
     }
     if ($this->getParam("component")) {
         $queryString .= " AND component =  '" . $this->getParam("component") . "'";
     }
     if ($this->getParam("relatedobject")) {
         $queryString .= " AND relatedobject = " . $this->getParam("relatedobject");
     }
     if ($this->getParam("message")) {
         $queryString .= " AND message like '%" . $this->getParam("message") . "%'";
     }
     $db = Db::get();
     $count = $db->fetchCol("SELECT count(*) FROM " . \Pimcore\Log\Handler\ApplicationLoggerDb::TABLE_NAME . $queryString);
     $total = $count[0];
     $result = $db->fetchAll("SELECT * FROM " . \Pimcore\Log\Handler\ApplicationLoggerDb::TABLE_NAME . $queryString . " {$orderby} LIMIT {$offset}, {$limit}");
     $errorDataList = array();
     if (!empty($result)) {
         foreach ($result as $r) {
             $parts = explode("/", $r['filelink']);
             $filename = $parts[count($parts) - 1];
             $fileobject = str_replace(PIMCORE_DOCUMENT_ROOT, "", $r['fileobject']);
             $errorData = array("id" => $r['id'], "pid" => $r['pid'], "message" => $r['message'], "timestamp" => $r['timestamp'], "priority" => $this->getPriorityName($r['priority']), "filename" => $filename, "fileobject" => $fileobject, "relatedobject" => $r['relatedobject'], "component" => $r['component'], "source" => $r['source']);
             $errorDataList[] = $errorData;
         }
     }
     $results = array("p_totalCount" => $total, "p_results" => $errorDataList);
     $this->_helper->json($results);
 }
开发者ID:cannonerd,项目名称:pimcore,代码行数:60,代码来源:LogController.php

示例2: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     // display error message
     if (!$input->getOption("mode")) {
         $this->writeError("Please specify the mode!");
         exit;
     }
     $db = \Pimcore\Db::get();
     if ($input->getOption("mode") == "optimize") {
         $tables = $db->fetchAll("SHOW TABLES");
         foreach ($tables as $table) {
             $t = current($table);
             try {
                 \Logger::debug("Running: OPTIMIZE TABLE " . $t);
                 $db->query("OPTIMIZE TABLE " . $t);
             } catch (\Exception $e) {
                 \Logger::error($e);
             }
         }
     } elseif ($input->getOption("mode") == "warmup") {
         $tables = $db->fetchAll("SHOW TABLES");
         foreach ($tables as $table) {
             $t = current($table);
             try {
                 \Logger::debug("Running: SELECT COUNT(*) FROM {$t}");
                 $res = $db->fetchOne("SELECT COUNT(*) FROM {$t}");
                 \Logger::debug("Result: " . $res);
             } catch (\Exception $e) {
                 \Logger::error($e);
             }
         }
     }
 }
开发者ID:solverat,项目名称:pimcore,代码行数:33,代码来源:MysqlToolsCommand.php

示例3: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $storeId = $input->getArgument('storeId');
     if (!is_numeric($storeId)) {
         throw new \Exception('Invalid store ID');
     }
     $db = Db::get();
     $tableList = $db->fetchAll("show tables like 'object_classificationstore_data_%'");
     foreach ($tableList as $table) {
         $theTable = current($table);
         $sql = "delete from " . $theTable . " where keyId In (select id from classificationstore_keys where storeId = " . $db->quote($storeId) . ")";
         echo $sql . "\n";
         $db->query($sql);
     }
     $tableList = $db->fetchAll("show tables like 'object_classificationstore_groups_%'");
     foreach ($tableList as $table) {
         $theTable = current($table);
         $sql = "delete from " . $theTable . " where groupId In (select id from classificationstore_groups where storeId = " . $db->quote($storeId) . ")";
         echo $sql . "\n";
         $db->query($sql);
     }
     $sql = "delete from classificationstore_keys where storeId = " . $db->quote($storeId);
     echo $sql . "\n";
     $db->query($sql);
     $sql = "delete from classificationstore_groups where storeId = " . $db->quote($storeId);
     echo $sql . "\n";
     $db->query($sql);
     $sql = "delete from classificationstore_collections where storeId = " . $db->quote($storeId);
     echo $sql . "\n";
     $db->query($sql);
     $sql = "delete from classificationstore_stores where id = " . $db->quote($storeId);
     echo $sql . "\n";
     $db->query($sql);
     Cache::clearAll();
 }
开发者ID:pimcore,项目名称:pimcore,代码行数:35,代码来源:DeleteClassificationStoreCommand.php

示例4: __construct

 /**
  * @param $classId
  * @param null $idField
  * @param null $storetable
  * @param null $querytable
  * @param null $relationtable
  */
 public function __construct($classId, $idField = null, $storetable = null, $querytable = null, $relationtable = null)
 {
     $this->db = \Pimcore\Db::get();
     $this->fields = array();
     $this->relations = array();
     $this->fieldIds = array();
     $this->deletionFieldIds = array();
     $this->fieldDefinitions = [];
     if ($storetable == null) {
         $this->storetable = self::STORE_TABLE . $classId;
     } else {
         $this->storetable = $storetable;
     }
     if ($querytable == null) {
         $this->querytable = self::QUERY_TABLE . $classId;
     } else {
         $this->querytable = $querytable;
     }
     if ($relationtable == null) {
         $this->relationtable = self::RELATION_TABLE . $classId;
     } else {
         $this->relationtable = $relationtable;
     }
     if ($idField == null) {
         $this->idField = self::ID_FIELD;
     } else {
         $this->idField = $idField;
     }
 }
开发者ID:emanuel-london,项目名称:pimcore,代码行数:36,代码来源:InheritanceHelper.php

示例5: indexAction

 public function indexAction()
 {
     $this->enableLayout();
     // get a list of news objects and order them by date
     $blogList = new Object\BlogArticle\Listing();
     $blogList->setOrderKey("date");
     $blogList->setOrder("DESC");
     $conditions = [];
     if ($this->getParam("category")) {
         $conditions[] = "categories LIKE " . $blogList->quote("%," . (int) $this->getParam("category") . ",%");
     }
     if ($this->getParam("archive")) {
         $conditions[] = "DATE_FORMAT(FROM_UNIXTIME(date), '%Y-%c') = " . $blogList->quote($this->getParam("archive"));
     }
     if (!empty($conditions)) {
         $blogList->setCondition(implode(" AND ", $conditions));
     }
     $paginator = \Zend_Paginator::factory($blogList);
     $paginator->setCurrentPageNumber($this->getParam('page'));
     $paginator->setItemCountPerPage(5);
     $this->view->articles = $paginator;
     // get all categories
     $categories = Object\BlogCategory::getList();
     // this is an alternative way to get an object list
     $this->view->categories = $categories;
     // archive information, we have to do this in pure SQL
     $db = \Pimcore\Db::get();
     $ranges = $db->fetchCol("SELECT DATE_FORMAT(FROM_UNIXTIME(date), '%Y-%c') as ranges FROM object_5 GROUP BY DATE_FORMAT(FROM_UNIXTIME(date), '%b-%Y') ORDER BY ranges ASC");
     $this->view->archiveRanges = $ranges;
 }
开发者ID:ChristophWurst,项目名称:pimcore,代码行数:30,代码来源:BlogController.php

示例6: getFilterCondition

 /**
  * Creates a condition string from the passed ExtJs filter definitions
  *
  * @param $filterString
  * @param array $matchExact
  * @param bool $returnString
  * @param array $callbacks
  * @return array|string
  * @throws \Exception
  */
 public static function getFilterCondition($filterString, $matchExact = ['id', 'o_id'], $returnString = true, $callbacks = [])
 {
     if (!$filterString) {
         return '';
     }
     $conditions = [];
     $filters = json_decode($filterString);
     $db = \Pimcore\Db::get();
     foreach ($filters as $f) {
         if ($f->type == 'string') {
             if (in_array($f->property, $matchExact)) {
                 $conditions[$f->property][] = ' ' . $db->getQuoteIdentifierSymbol() . $f->property . $db->getQuoteIdentifierSymbol() . " = " . $db->quote($f->value) . ' ';
             } else {
                 $conditions[$f->property][] = ' ' . $db->getQuoteIdentifierSymbol() . $f->property . $db->getQuoteIdentifierSymbol() . " LIKE " . $db->quote("%" . $f->value . "%") . ' ';
             }
         } elseif ($f->type == 'numeric') {
             if ($f->operator == 'eq') {
                 $symbol = ' = ';
             } elseif ($f->operator == 'lt') {
                 $symbol = ' < ';
             } elseif ($f->operator == 'gt') {
                 $symbol = ' > ';
             }
             $conditions[$f->property][] = ' ' . $db->getQuoteIdentifierSymbol() . $f->property . $db->getQuoteIdentifierSymbol() . $symbol . $db->quote($f->value) . ' ';
         } elseif ($f->type == 'date') {
             /**
              * make sure you pass the date as timestamp
              *
              * filter: {type : 'date',dateFormat: 'timestamp'}
              */
             $date = Carbon::createFromTimestamp($f->value)->setTime(0, 0, 0);
             if ($f->operator == 'eq') {
                 $conditions[$f->property][] = ' ' . $f->property . ' >= ' . $db->quote($date->getTimestamp());
                 $conditions[$f->property][] = ' ' . $f->property . ' <= ' . $db->quote($date->addDay(1)->subSecond(1)->getTimestamp());
             } elseif ($f->operator == 'lt') {
                 $conditions[$f->property][] = ' ' . $f->property . ' < ' . $db->quote($date->getTimestamp());
             } elseif ($f->operator == 'gt') {
                 $conditions[$f->property][] = ' ' . $f->property . ' > ' . $db->quote($date->addDay(1)->subSecond(1)->getTimestamp());
             }
         } else {
             throw new \Exception("Filer of type " . $f->type . " not jet supported.");
         }
     }
     $conditionsGrouped = [];
     foreach ($conditions as $fieldName => $fieldConditions) {
         if (count($fieldConditions) > 1) {
             $conditionsGrouped[$fieldName] = ' (' . implode(' AND ', $fieldConditions) . ') ';
         } else {
             $conditionsGrouped[$fieldName] = $fieldConditions[0];
         }
     }
     if ($returnString) {
         return implode(' OR ', $conditionsGrouped);
     } else {
         return $conditionsGrouped;
     }
 }
开发者ID:solverat,项目名称:pimcore,代码行数:67,代码来源:QueryParams.php

示例7: showAction

 public function showAction()
 {
     $offset = $this->_getParam("start");
     $limit = $this->_getParam("limit");
     $orderby = "ORDER BY id DESC";
     $sortingSettings = \Pimcore\Admin\Helper\QueryParams::extractSortingSettings($this->getAllParams());
     if ($sortingSettings['orderKey']) {
         $orderby = "ORDER BY " . $sortingSettings['orderKey'] . " " . $sortingSettings['order'];
     }
     $queryString = " WHERE 1=1";
     if ($this->_getParam("priority") != "-1" && ($this->_getParam("priority") == "0" || $this->_getParam("priority"))) {
         $queryString .= " AND priority <= " . $this->_getParam("priority");
     } else {
         $queryString .= " AND (priority = 6 OR priority = 5 OR priority = 4 OR priority = 3 OR priority = 2 OR priority = 1 OR priority = 0)";
     }
     if ($this->_getParam("fromDate")) {
         $datetime = $this->_getParam("fromDate");
         if ($this->_getParam("fromTime")) {
             $datetime = substr($datetime, 0, 11) . $this->_getParam("fromTime") . ":00";
         }
         $queryString .= " AND timestamp >= '" . $datetime . "'";
     }
     if ($this->_getParam("toDate")) {
         $datetime = $this->_getParam("toDate");
         if ($this->_getParam("toTime")) {
             $datetime = substr($datetime, 0, 11) . $this->_getParam("toTime") . ":00";
         }
         $queryString .= " AND timestamp <= '" . $datetime . "'";
     }
     if ($this->_getParam("component")) {
         $queryString .= " AND component =  '" . $this->_getParam("component") . "'";
     }
     if ($this->_getParam("relatedobject")) {
         $queryString .= " AND relatedobject = " . $this->_getParam("relatedobject");
     }
     if ($this->_getParam("message")) {
         $queryString .= " AND message like '%" . $this->_getParam("message") . "%'";
     }
     $db = Db::get();
     $count = $db->fetchCol("SELECT count(*) FROM " . Log\Helper::ERROR_LOG_TABLE_NAME . $queryString);
     $total = $count[0];
     $result = $db->fetchAll("SELECT * FROM " . Log\Helper::ERROR_LOG_TABLE_NAME . $queryString . " {$orderby} LIMIT {$offset}, {$limit}");
     $errorDataList = array();
     if (!empty($result)) {
         foreach ($result as $r) {
             $parts = explode("/", $r['filelink']);
             $filename = $parts[count($parts) - 1];
             $fileobject = str_replace(PIMCORE_DOCUMENT_ROOT, "", $r['fileobject']);
             $errorData = array("id" => $r['id'], "message" => $r['message'], "timestamp" => $r['timestamp'], "priority" => $this->getPriorityName($r['priority']), "filename" => $filename, "fileobject" => $fileobject, "relatedobject" => $r['relatedobject'], "component" => $r['component'], "source" => $r['source']);
             $errorDataList[] = $errorData;
         }
     }
     $results = array("p_totalCount" => $total, "p_results" => $errorDataList);
     $this->_helper->json($results);
 }
开发者ID:ChristophWurst,项目名称:pimcore,代码行数:55,代码来源:LogController.php

示例8: getPriorities

 /**
  * @static
  * @return string[]
  */
 public static function getPriorities()
 {
     $priorities = array();
     $priorityNames = array("debug" => "DEBUG", "info" => "INFO", "notice" => "NOTICE", "warning" => "WARN", "error" => "ERR", "critical" => "CRIT", "alert" => "ALERT", "emergency" => "EMERG");
     $db = Database::get();
     $priorityNumbers = $db->fetchCol("SELECT priority FROM " . \Pimcore\Log\Handler\ApplicationLoggerDb::TABLE_NAME . " WHERE NOT ISNULL(priority) GROUP BY priority;");
     foreach ($priorityNumbers as $priorityNumber) {
         $priorities[$priorityNumber] = $priorityNames[$priorityNumber];
     }
     return $priorities;
 }
开发者ID:emanuel-london,项目名称:pimcore,代码行数:15,代码来源:ApplicationLoggerDb.php

示例9: getPriorities

 /**
  * @static
  * @return string[]
  */
 public static function getPriorities()
 {
     $priorities = array();
     $priorityNames = array(Zend_Log::DEBUG => "DEBUG", Zend_Log::INFO => "INFO", Zend_Log::NOTICE => "INFO", Zend_Log::WARN => "WARN", Zend_Log::ERR => "ERR", Zend_Log::CRIT => "CRIT", Zend_Log::ALERT => "ALERT", Zend_Log::EMERG => "EMERG");
     $db = Database::get();
     $priorityNumbers = $db->fetchCol("SELECT priority FROM " . Log\Helper::ERROR_LOG_TABLE_NAME . " WHERE NOT ISNULL(priority) GROUP BY priority;");
     foreach ($priorityNumbers as $priorityNumber) {
         $priorities[$priorityNumber] = $priorityNames[$priorityNumber];
     }
     return $priorities;
 }
开发者ID:ChristophWurst,项目名称:pimcore,代码行数:15,代码来源:Db.php

示例10: routeShutdown

 /**
  * @param \Zend_Controller_Request_Abstract $request
  * @return bool|void
  */
 public function routeShutdown(\Zend_Controller_Request_Abstract $request)
 {
     if (!Tool::useFrontendOutputFilters($request)) {
         return $this->disable();
     }
     $db = \Pimcore\Db::get();
     $enabled = $db->fetchOne("SELECT id FROM targeting_personas UNION SELECT id FROM targeting_rules LIMIT 1");
     if (!$enabled) {
         return $this->disable();
     }
     if ($request->getParam("document") instanceof Document\Page) {
         $this->document = $request->getParam("document");
     }
 }
开发者ID:quorak,项目名称:pimcore,代码行数:18,代码来源:Targeting.php

示例11: writeLog

 /**
  *
  */
 public function writeLog()
 {
     $code = (string) $this->getResponse()->getHttpResponseCode();
     $db = \Pimcore\Db::get();
     try {
         $uri = $this->getRequest()->getScheme() . "://" . $this->getRequest()->getHttpHost() . $this->getRequest()->getRequestUri();
         $exists = $db->fetchOne("SELECT date FROM http_error_log WHERE uri = ?", $uri);
         if ($exists) {
             $db->query("UPDATE http_error_log SET `count` = `count` + 1, date = ? WHERE uri = ?", [time(), $uri]);
         } else {
             $db->insert("http_error_log", ["uri" => $uri, "code" => (int) $code, "parametersGet" => serialize($_GET), "parametersPost" => serialize($_POST), "cookies" => serialize($_COOKIE), "serverVars" => serialize($_SERVER), "date" => time(), "count" => 1]);
         }
     } catch (\Exception $e) {
         \Logger::error("Unable to log http error");
         \Logger::error($e);
     }
 }
开发者ID:solverat,项目名称:pimcore,代码行数:20,代码来源:HttpErrorLog.php

示例12: getByKeyAndLanguage

 /**
  * @param $key
  * @param $language
  * @return \Pimcore\Model\Metadata\Predefined
  */
 public static function getByKeyAndLanguage($key, $language, $targetSubtype = null)
 {
     $db = \Pimcore\Db::get();
     $list = new self();
     $condition = "name = " . $db->quote($key);
     if ($language) {
         $condition .= " AND language = " . $db->quote($language);
     } else {
         $condition .= " AND (language = '' OR LANGUAGE IS NULL)";
     }
     if ($targetSubtype) {
         $condition .= " AND targetSubtype = " . $db->quote($targetSubtype);
     }
     $list->setCondition($condition);
     $list = $list->load();
     if ($list) {
         return $list[0];
     }
     return null;
 }
开发者ID:sfie,项目名称:pimcore,代码行数:25,代码来源:Listing.php

示例13: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     // clear all data
     $db = \Pimcore\Db::get();
     $db->query("TRUNCATE `search_backend_data`;");
     $elementsPerLoop = 100;
     $types = ["asset", "document", "object"];
     foreach ($types as $type) {
         $listClassName = "\\Pimcore\\Model\\" . ucfirst($type) . "\\Listing";
         $list = new $listClassName();
         if (method_exists($list, "setUnpublished")) {
             $list->setUnpublished(true);
         }
         $elementsTotal = $list->getTotalCount();
         for ($i = 0; $i < ceil($elementsTotal / $elementsPerLoop); $i++) {
             $list->setLimit($elementsPerLoop);
             $list->setOffset($i * $elementsPerLoop);
             $this->output->writeln("Processing " . $type . ": " . ($list->getOffset() + $elementsPerLoop) . "/" . $elementsTotal);
             $elements = $list->load();
             foreach ($elements as $element) {
                 try {
                     $searchEntry = Search\Backend\Data::getForElement($element);
                     if ($searchEntry instanceof Search\Backend\Data and $searchEntry->getId() instanceof Search\Backend\Data\Id) {
                         $searchEntry->setDataFromElement($element);
                     } else {
                         $searchEntry = new Search\Backend\Data($element);
                     }
                     $searchEntry->save();
                 } catch (\Exception $e) {
                     Logger::err($e);
                 }
             }
             \Pimcore::collectGarbage();
         }
     }
     $db->query("OPTIMIZE TABLE search_backend_data;");
 }
开发者ID:pimcore,项目名称:pimcore,代码行数:37,代码来源:SearchBackendReindexCommand.php

示例14: archiveLogEntries

 public function archiveLogEntries()
 {
     $conf = Config::getSystemConfig();
     $config = $conf->applicationlog;
     $db = \Pimcore\Db::get();
     $tablename = \Pimcore\Log\Handler\ApplicationLoggerDb::TABLE_ARCHIVE_PREFIX . "_" . \Zend_Date::now()->get(\Zend_Date::MONTH) . '_' . \Zend_Date::now()->get(\Zend_Date::YEAR);
     if ($config->archive_alternative_database) {
         $tablename = $config->archive_alternative_database . '.' . $tablename;
     }
     $archive_treshold = intval($config->archive_treshold) ?: 30;
     $db->query("CREATE TABLE IF NOT EXISTS " . $tablename . " (\n                       id BIGINT(20) NOT NULL,\n                       `pid` INT(11) NULL DEFAULT NULL,\n                       `timestamp` DATETIME NOT NULL,\n                       message VARCHAR(1024),\n                       `priority` ENUM('emergency','alert','critical','error','warning','notice','info','debug') DEFAULT NULL,\n                       fileobject VARCHAR(1024),\n                       info VARCHAR(1024),\n                       component VARCHAR(255),\n                       source VARCHAR(255) NULL DEFAULT NULL,\n                       relatedobject BIGINT(20),\n                       relatedobjecttype ENUM('object', 'document', 'asset'),\n                       maintenanceChecked TINYINT(4)\n                    ) ENGINE = ARCHIVE ROW_FORMAT = DEFAULT;");
     $timestamp = time();
     $db->query("INSERT INTO " . $tablename . " SELECT * FROM " . \Pimcore\Log\Handler\ApplicationLoggerDb::TABLE_NAME . " WHERE `timestamp` < DATE_SUB(FROM_UNIXTIME(" . $timestamp . "), INTERVAL " . $archive_treshold . " DAY);");
     $db->query("DELETE FROM " . \Pimcore\Log\Handler\ApplicationLoggerDb::TABLE_NAME . " WHERE `timestamp` < DATE_SUB(FROM_UNIXTIME(" . $timestamp . "), INTERVAL " . $archive_treshold . " DAY);");
 }
开发者ID:cannonerd,项目名称:pimcore,代码行数:15,代码来源:Maintenance.php

示例15: quote

 /**
  * @param  $value
  * @return string
  */
 public function quote($value, $type = null)
 {
     $db = Db::get();
     return $db->quote($value, $type);
 }
开发者ID:sfie,项目名称:pimcore,代码行数:9,代码来源:AbstractListing.php


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