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


PHP DBAdapter::prepareParams方法代码示例

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


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

示例1: prepareParams

    /**
     * Prepare connection parameters.
     * See: http://www.propelorm.org/ticket/1360
     *
     * @param  array $params
     * @return array
     *
     * @throws PropelException
     */
    public function prepareParams($params)
    {
        $params = parent::prepareParams($params);
        // Whitelist based on https://bugs.php.net/bug.php?id=47802
        // And https://bugs.php.net/bug.php?id=47802
        $whitelist = array('ASCII', 'CP1250', 'CP1251', 'CP1252', 'CP1256', 'CP1257', 'GREEK', 'HEBREW', 'LATIN1', 'LATIN2', 'LATIN5', 'LATIN7', 'SWE7', 'UTF8', 'UTF-8');
        if (isset($params['settings']['charset']['value'])) {
            if (version_compare(PHP_VERSION, '5.3.6', '<')) {
                $charset = strtoupper($params['settings']['charset']['value']);
                if (!in_array($charset, $whitelist)) {
                    throw new PropelException(<<<EXCEPTION
Connection option "charset" cannot be used for MySQL connections in PHP versions older than 5.3.6.
    Please refer to http://www.propelorm.org/ticket/1360 for instructions and details about the implications of
    using a SET NAMES statement in the "queries" setting.
EXCEPTION
);
                }
            } else {
                if (strpos($params['dsn'], ';charset=') === false) {
                    $params['dsn'] .= ';charset=' . $params['settings']['charset']['value'];
                    unset($params['settings']['charset']);
                }
            }
        }
        return $params;
    }
开发者ID:keneanung,项目名称:gw2spidy,代码行数:35,代码来源:DBMySQL.php

示例2: prepareParams

    /**
     * Prepare connection parameters.
     * See: http://www.propelorm.org/ticket/1360
     *
     * @param array	$params
     * @return array
     */
    public function prepareParams($params)
    {
        $params = parent::prepareParams($params);
        if (isset($params['settings']['charset']['value'])) {
            if (version_compare(PHP_VERSION, '5.3.6', '<')) {
                throw new PropelException(<<<EXCEPTION
Connection option "charset" cannot be used for MySQL connections in PHP versions older than 5.3.6.
Please refer to http://www.propelorm.org/ticket/1360 for instructions and details about the implications of
using a SET NAMES statement in the "queries" setting.
EXCEPTION
);
            } else {
                if (strpos($params['dsn'], ';charset=') === false) {
                    $params['dsn'] .= ';charset=' . $params['settings']['charset']['value'];
                    unset($params['settings']['charset']);
                }
            }
        }
        return $params;
    }
开发者ID:homer6,项目名称:Propel,代码行数:27,代码来源:DBMySQL.php


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