本文整理汇总了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;
}
示例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;
}