本文整理匯總了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;
}