當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。