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


PHP xPDO类代码示例

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


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

示例1: loadOptions

 public static function loadOptions(xPDO &$xpdo, $product)
 {
     $c = $xpdo->newQuery('msProductOption');
     $c->rightJoin('msOption', 'msOption', 'msProductOption.key=msOption.key');
     $c->leftJoin('modCategory', 'Category', 'Category.id=msOption.category');
     $c->where(array('msProductOption.product_id' => $product));
     $c->select($xpdo->getSelectColumns('msOption', 'msOption'));
     $c->select($xpdo->getSelectColumns('msProductOption', 'msProductOption', '', array('key'), true));
     $c->select('`Category`.`category` AS `category_name`');
     $data = array();
     $tstart = microtime(true);
     if ($c->prepare() && $c->stmt->execute()) {
         $xpdo->queryTime += microtime(true) - $tstart;
         $xpdo->executedQueries++;
         while ($option = $c->stmt->fetch(PDO::FETCH_ASSOC)) {
             if (isset($data[$option['key']])) {
                 // если опция повторяется, ее значение будет массивом
                 if (!is_array($data[$option['key']])) {
                     $data[$option['key']] = array($data[$option['key']]);
                 }
                 $data[$option['key']][] = $option['value'];
             } else {
                 // одиночная опция останется строкой
                 $data[$option['key']] = $option['value'];
             }
             foreach ($option as $key => $value) {
                 $data[$option['key'] . '.' . $key] = $value;
             }
         }
     }
     return $data;
 }
开发者ID:rafull6,项目名称:texno-service,代码行数:32,代码来源:msproductdata.class.php

示例2: listEvents

 public static function listEvents(xPDO &$xpdo, $plugin, array $criteria = array(), array $sort = array('id' => 'ASC'), $limit = 0, $offset = 0) {
     $c = $xpdo->newQuery('modEvent');
     $count = $xpdo->getCount('modEvent',$c);
     $c->select(array(
         'modEvent.*',
         'IF(ISNULL(modPluginEvent.pluginid),0,1) AS enabled',
         'modPluginEvent.priority AS priority',
         'modPluginEvent.propertyset AS propertyset',
     ));
     $c->leftJoin('modPluginEvent','modPluginEvent','
         modPluginEvent.event = modEvent.name
         AND modPluginEvent.pluginid = '.$plugin.'
     ');
     $c->where($criteria);
     foreach($sort as $field=> $dir) {
         $c->sortby($xpdo->getSelectColumns('modEvent','modEvent','',array($field)),$dir);
     }
     if ((int) $limit > 0) {
         $c->limit((int) $limit, (int) $offset);
     }
     return array(
         'count'=> $count,
         'collection'=> $xpdo->getCollection('modEvent',$c)
     );
 }
开发者ID:raf3600,项目名称:revolution,代码行数:25,代码来源:modevent.class.php

示例3: _getControllerPath

 public static function _getControllerPath(xPDO &$modx, $path)
 {
     if (!($_path = $modx->getOption('shopmodx.core_path', null))) {
         $_path = $modx->getOption('core_path') . 'components/shopmodx/';
     }
     $_path .= "controllers/default/{$path}/";
     return $_path;
 }
开发者ID:Tramp1357,项目名称:atlasorg,代码行数:8,代码来源:shopmodxresource.class.php

示例4: getDefaultDashboard

 /**
  * Get the default MODX dashboard
  * @static
  * @param xPDO $xpdo A reference to an xPDO instance
  * @return An|null|object
  */
 public static function getDefaultDashboard(xPDO &$xpdo)
 {
     /** @var modDashboard $defaultDashboard */
     $defaultDashboard = $xpdo->getObject('modDashboard', array('id' => 1));
     if (empty($defaultDashboard)) {
         $defaultDashboard = $xpdo->getObject('modDashboard', array('name' => 'Default'));
     }
     return $defaultDashboard;
 }
开发者ID:e-gob,项目名称:apps.gob.cl,代码行数:15,代码来源:moddashboard.class.php

示例5: getControllerPath

 public static function getControllerPath(xPDO &$modx)
 {
     $path = $modx->getOption('modsociety.controller_path', null);
     if (empty($path)) {
         $path = $modx->getOption('modsociety.core_path', null, $modx->getOption('core_path', null) . 'components/modsociety/') . 'controllers/mgr/';
     }
     $path .= "societytopic/";
     return $path;
 }
开发者ID:bendasvadim,项目名称:NewsModxBox,代码行数:9,代码来源:societytopic.class.php

示例6: listSettings

    public static function listSettings(xPDO &$xpdo, array $criteria = array(), array $sort = array('id' => 'ASC'), $limit = 0, $offset = 0) {
        /* build query */
        $c = $xpdo->newQuery('modSystemSetting');
        $c->select(array(
            $xpdo->getSelectColumns('modSystemSetting','modSystemSetting'),
        ));
        $c->select(array(
            'name_trans' => 'Entry.value',
            'description_trans' => 'Description.value',
        ));
        $c->leftJoin('modLexiconEntry','Entry',"CONCAT('setting_',modSystemSetting.{$xpdo->escape('key')}) = Entry.name");
        $c->leftJoin('modLexiconEntry','Description',"CONCAT('setting_',modSystemSetting.{$xpdo->escape('key')},'_desc') = Description.name");
        $c->where($criteria);

        $count = $xpdo->getCount('modSystemSetting',$c);
        $c->sortby($xpdo->getSelectColumns('modSystemSetting','modSystemSetting','',array('area')),'ASC');
        foreach($sort as $field=> $dir) {
            $c->sortby($xpdo->getSelectColumns('modSystemSetting','modSystemSetting','',array($field)),$dir);
        }
        if ((int) $limit > 0) {
            $c->limit((int) $limit, (int) $offset);
        }
        $c->prepare();
        return array(
            'count'=> $count,
            'collection'=> $xpdo->getCollection('modSystemSetting',$c)
        );
    }
开发者ID:raf3600,项目名称:revolution,代码行数:28,代码来源:modsystemsetting.class.php

示例7: removeSourceContainer

 public function removeSourceContainer($dsnArray = null, $username = null, $password = null)
 {
     $removed = false;
     if ($dsnArray === null) {
         $dsnArray = xPDO::parseDSN($this->xpdo->getOption('dsn'));
     }
     if ($username === null) {
         $username = $this->xpdo->getOption('username', null, '');
     }
     if ($password === null) {
         $password = $this->xpdo->getOption('password', null, '');
     }
     if (is_array($dsnArray) && is_string($username) && is_string($password)) {
         $sql = 'DROP DATABASE ' . $this->xpdo->escape($dsnArray['dbname']);
         try {
             $pdo = new PDO("mysql:host={$dsnArray['host']}", $username, $password, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
             $result = $pdo->exec($sql);
             if ($result !== false) {
                 $removed = true;
             } else {
                 $this->xpdo->log(xPDO::LOG_LEVEL_ERROR, "Could not remove source container:\n{$sql}\nresult = " . var_export($result, true));
             }
         } catch (PDOException $pe) {
             $this->xpdo->log(xPDO::LOG_LEVEL_ERROR, "Could not connect to database server: " . $pe->getMessage());
         } catch (Exception $e) {
             $this->xpdo->log(xPDO::LOG_LEVEL_ERROR, "Could not remove source container: " . $e->getMessage());
         }
     }
     return $removed;
 }
开发者ID:JoeBlow,项目名称:revolution,代码行数:30,代码来源:xpdomanager.class.php

示例8: removeSourceContainer

 public function removeSourceContainer($dsnArray = null, $username = null, $password = null)
 {
     $removed = false;
     if ($this->xpdo->getConnection(array(xPDO::OPT_CONN_MUTABLE => true))) {
         if ($dsnArray === null) {
             $dsnArray = xPDO::parseDSN($this->xpdo->getOption('dsn'));
         }
         if ($username === null) {
             $username = $this->xpdo->getOption('username', null, '');
         }
         if ($password === null) {
             $password = $this->xpdo->getOption('password', null, '');
         }
         if (is_array($dsnArray) && is_string($username) && is_string($password)) {
             $sql = 'DROP DATABASE ' . $this->xpdo->escape($dsnArray['dbname']);
             try {
                 $pdo = new PDO("sqlsrv:server={$dsnArray['server']}", $username, $password, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
                 $pdo->exec("ALTER DATABASE {$this->xpdo->escape($dsnArray['dbname'])} SET single_user WITH ROLLBACK IMMEDIATE");
                 $result = $pdo->exec($sql);
                 if ($result !== false) {
                     $removed = true;
                 } else {
                     $this->xpdo->log(xPDO::LOG_LEVEL_ERROR, "Could not remove source container:\n{$sql}\nresult = " . var_export($result, true));
                 }
             } catch (PDOException $pe) {
                 $this->xpdo->log(xPDO::LOG_LEVEL_ERROR, "Could not connect to database server: " . $pe->getMessage());
             } catch (Exception $e) {
                 $this->xpdo->log(xPDO::LOG_LEVEL_ERROR, "Could not remove source container: " . $e->getMessage());
             }
         }
     } else {
         $this->xpdo->log(xPDO::LOG_LEVEL_ERROR, "Could not get writable connection", '', __METHOD__, __FILE__, __LINE__);
     }
     return $removed;
 }
开发者ID:DeFi-ManriquezLuis,项目名称:MTLTransfer,代码行数:35,代码来源:xpdomanager.class.php

示例9: initialize

 public function initialize()
 {
     $this->setDefaultProperties(array('classKey' => 'modSnippet', 'pk' => false));
     $tagParts = xPDO::escSplit('?', $this->getProperty('tag'), '`', 2);
     $tagNameParts = xPDO::escSplit('@', $tagParts[0]);
     $propertySet = isset($tagNameParts[1]) ? trim($tagNameParts[1]) : null;
     if (isset($propertySet) && strpos($propertySet, ':') != false) {
         $propSetParts = xPDO::escSplit(':', $propertySet);
         $propertySet = trim($propSetParts[0]);
     }
     if (isset($propertySet) && ($ps = $this->modx->getObject('modPropertySet', array('name' => $propertySet)))) {
         $this->setProperty('propertySet', $ps->id);
     }
     if (isset($tagParts[1])) {
         $tagPropString = ltrim(trim($tagParts[1]), '&');
         $this->tagProperties = $this->modx->getParser()->parseProperties($tagPropString);
     }
     //$this->modx->log(1,print_r($this->tagProperties,1));
     //$this->modx->log(modX::LOG_LEVEL_ERROR, $this->getProperty('tag'));
     $this->element = $this->modx->getObject($this->getProperty('classKey'), $this->getProperty('pk'));
     if (empty($this->element)) {
         return $this->modx->lexicon('element_err_nf');
     }
     return true;
 }
开发者ID:sergant210,项目名称:tagElementPlugin,代码行数:25,代码来源:getinsertproperties.class.php

示例10: loadCollection

 /**
  * Custom collection loader that forces access policy checking.
  *
  * {@inheritdoc}
  */
 public static function loadCollection(xPDO &$xpdo, $className, $criteria = null, $cacheFlag = true)
 {
     $objCollection = array();
     if (!($className = $xpdo->loadClass($className))) {
         return $objCollection;
     }
     $rows = false;
     $fromCache = false;
     $collectionCaching = (int) $xpdo->getOption(xPDO::OPT_CACHE_DB_COLLECTIONS, array(), 1);
     if (!is_object($criteria)) {
         $criteria = $xpdo->getCriteria($className, $criteria, $cacheFlag);
     }
     if (is_object($criteria)) {
         if ($collectionCaching > 0 && $xpdo->_cacheEnabled && $cacheFlag) {
             $rows = $xpdo->fromCache($criteria, $className);
             $fromCache = is_array($rows) && !empty($rows);
         }
         if (!$fromCache) {
             $rows = xPDOObject::_loadRows($xpdo, $className, $criteria);
         }
         $cacheRows = array();
         if (is_array($rows)) {
             foreach ($rows as $row) {
                 if (modAccessibleObject::_loadCollectionInstance($xpdo, $objCollection, $className, $criteria, $row, $fromCache, $cacheFlag)) {
                     if ($collectionCaching > 0 && $xpdo->_cacheEnabled && $cacheFlag && !$fromCache) {
                         $cacheRows[] = $row;
                     }
                 }
             }
         } elseif (is_object($rows)) {
             while ($row = $rows->fetch(PDO::FETCH_ASSOC)) {
                 if (modAccessibleObject::_loadCollectionInstance($xpdo, $objCollection, $className, $criteria, $row, $fromCache, $cacheFlag)) {
                     if ($collectionCaching > 0 && $xpdo->_cacheEnabled && $cacheFlag && !$fromCache) {
                         $cacheRows[] = $row;
                     }
                 }
             }
         }
         if (!$fromCache && $xpdo->_cacheEnabled && $collectionCaching > 0 && $cacheFlag && !empty($cacheRows)) {
             $xpdo->toCache($criteria, $cacheRows, $cacheFlag);
         }
     } else {
         $xpdo->log(xPDO::LOG_LEVEL_ERROR, 'modAccessibleObject::loadCollection() - No valid statement could be found in or generated from the given criteria.');
     }
     return $objCollection;
 }
开发者ID:JoeBlow,项目名称:revolution,代码行数:51,代码来源:modaccessibleobject.class.php

示例11: processTag

 public function processTag($tag, $processUncacheable = true)
 {
     // We need only # placeholders
     if ($tag[1][0] !== '#' && strpos($tag[1], '!#') === false) {
         return parent::processTag($tag, $processUncacheable);
     }
     $this->_processingTag = true;
     $element = null;
     $elementOutput = null;
     $outerTag = $tag[0];
     $innerTag = $tag[1];
     /* collect any nested element tags in the innerTag and process them */
     $this->processElementTags($outerTag, $innerTag, $processUncacheable);
     $this->_processingTag = true;
     $outerTag = '[[' . $innerTag . ']]';
     $tagParts = xPDO::escSplit('?', $innerTag, '`', 2);
     $tagName = trim($tagParts[0]);
     $tagPropString = null;
     if (isset($tagParts[1])) {
         $tagPropString = trim($tagParts[1]);
     }
     $token = substr($tagName, 0, 1);
     $tokenOffset = 0;
     $cacheable = true;
     if ($token === '!') {
         if (!$processUncacheable) {
             $this->_processingTag = false;
             return $outerTag;
         }
         $cacheable = false;
         $tokenOffset++;
         $token = substr($tagName, $tokenOffset, 1);
     }
     if ($cacheable && $token !== '+') {
         $elementOutput = $this->loadFromCache($outerTag);
     }
     if ($elementOutput === null) {
         switch ($token) {
             case '#':
                 include_once $this->modx->getOption('core_path') . 'components/fastfield/model/fastfield/fastfield.php';
                 $tagName = substr($tagName, 1 + $tokenOffset);
                 $element = new modResourceFieldTag($this->modx);
                 $element->set('name', $tagName);
                 $element->setTag($outerTag);
                 $element->setCacheable($cacheable);
                 $elementOutput = $element->process($tagPropString);
                 break;
         }
     }
     if (($elementOutput === null || $elementOutput === false) && $outerTag !== $tag[0]) {
         $elementOutput = $outerTag;
     }
     if ($this->modx->getDebug() === true) {
         $this->modx->log(xPDO::LOG_LEVEL_DEBUG, "Processing {$outerTag} as {$innerTag} using tagname {$tagName}:\n" . print_r($elementOutput, 1) . "\n\n");
     }
     $this->_processingTag = false;
     return $elementOutput;
 }
开发者ID:raadhuis,项目名称:modx-basic,代码行数:58,代码来源:fastfieldparser.class.php

示例12: listProfiles

    public static function listProfiles(xPDO &$xpdo, array $criteria = array(), array $sort = array('id' => 'ASC'), $limit = 0, $offset = 0) {
        /* query for profiles */
        $c = $xpdo->newQuery('modFormCustomizationProfile');
        $c->select(array(
            'modFormCustomizationProfile.*',
        ));
        $c->select('
            (SELECT GROUP_CONCAT(UserGroup.name) FROM '.$xpdo->getTableName('modUserGroup').' AS UserGroup
                INNER JOIN '.$xpdo->getTableName('modFormCustomizationProfileUserGroup').' AS fcpug
                ON fcpug.usergroup = UserGroup.id
             WHERE fcpug.profile = modFormCustomizationProfile.id
            ) AS usergroups
        ');
        $c->where($criteria,null,2);// also log issue in remine to look at this usage of where()
        $count = $xpdo->getCount('modFormCustomizationProfile',$c);

        foreach($sort as $field=> $dir) {
            $c->sortby($xpdo->getSelectColumns('modFormCustomizationProfile','modFormCustomizationProfile','',array($field)),$dir);
        }
        if ((int) $limit > 0) {
            $c->limit((int) $limit, (int) $offset);
        }
        return array(
            'count'=> $count,
            'collection'=> $xpdo->getCollection('modFormCustomizationProfile',$c)
        );
    }
开发者ID:raf3600,项目名称:revolution,代码行数:27,代码来源:modformcustomizationprofile.class.php

示例13: _connect

 /**
  * Creates the database connection for the installation process.
  *
  * @access private
  * @return xPDO The xPDO instance to be used by the installation.
  */
 public function _connect($dsn, $user = '', $password = '', $prefix = '', array $options = array())
 {
     if (include_once MODX_CORE_PATH . 'xpdo/xpdo.class.php') {
         $this->xpdo = new xPDO($dsn, $user, $password, array_merge(array(xPDO::OPT_CACHE_PATH => MODX_CORE_PATH . 'cache/', xPDO::OPT_TABLE_PREFIX => $prefix, xPDO::OPT_SETUP => true), $options), array(PDO::ATTR_ERRMODE => PDO::ERRMODE_SILENT));
         $this->xpdo->setLogTarget(array('target' => 'FILE', 'options' => array('filename' => 'install.' . MODX_CONFIG_KEY . '.' . strftime('%Y%m%dT%H%M%S') . '.log')));
         $this->xpdo->setLogLevel(xPDO::LOG_LEVEL_ERROR);
         return $this->xpdo;
     } else {
         return $this->lexicon('xpdo_err_nf', array('path' => MODX_CORE_PATH . 'xpdo/xpdo.class.php'));
     }
 }
开发者ID:rosstimson,项目名称:revolution,代码行数:17,代码来源:modinstall.class.php

示例14: testInitialize

 public function testInitialize()
 {
     $xpdo = $this->getXPDOObject();
     if ($xpdo && $xpdo->connect()) {
         $response = $xpdo->getManager()->removeSourceContainer(xPDO::parseDSN($this->properties[$this->properties['xpdo_driver'] . '_string_dsn_test']));
         if ($response) {
             $xpdo = null;
         }
     } else {
         $xpdo = null;
     }
     $this->assertTrue($xpdo == null, "Test container exists and could not be removed for initialization");
 }
开发者ID:christianseel,项目名称:xpdo,代码行数:13,代码来源:XPDOTest.php

示例15: loadCache

 /**
  * @static
  * @param xPDO|modX $modx
  * @return array|mixed
  */
 public static function loadCache(xPDO &$modx)
 {
     if (!$modx->getCacheManager()) {
         return array();
     }
     $cacheKey = 'extension-packages';
     $cache = $modx->cacheManager->get($cacheKey, array(xPDO::OPT_CACHE_KEY => $modx->getOption('cache_extension_packages_key', null, 'namespaces'), xPDO::OPT_CACHE_HANDLER => $modx->getOption('cache_extension_packages_handler', null, $modx->getOption(xPDO::OPT_CACHE_HANDLER)), xPDO::OPT_CACHE_FORMAT => (int) $modx->getOption('cache_extension_packages_format', null, $modx->getOption(xPDO::OPT_CACHE_FORMAT, null, xPDOCacheManager::CACHE_PHP))));
     if (empty($cache)) {
         $cache = $modx->cacheManager->generateExtensionPackagesCache($cacheKey);
     }
     return $cache;
 }
开发者ID:raadhuis,项目名称:modx-basic,代码行数:17,代码来源:modextensionpackage.class.php


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