本文整理汇总了PHP中ConfigFile::getDbEntry方法的典型用法代码示例。如果您正苦于以下问题:PHP ConfigFile::getDbEntry方法的具体用法?PHP ConfigFile::getDbEntry怎么用?PHP ConfigFile::getDbEntry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConfigFile
的用法示例。
在下文中一共展示了ConfigFile::getDbEntry方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getValidators
/**
* Returns validator list
*
* @param ConfigFile $cf Config file instance
*
* @return array
*/
public static function getValidators(ConfigFile $cf)
{
static $validators = null;
if ($validators === null) {
$validators = $cf->getDbEntry('_validators', array());
if (!defined('PMA_SETUP')) {
// not in setup script: load additional validators for user
// preferences we need original config values not overwritten
// by user preferences, creating a new PMA_Config instance is a
// better idea than hacking into its code
$uvs = $cf->getDbEntry('_userValidators', array());
foreach ($uvs as $field => $uv_list) {
$uv_list = (array) $uv_list;
foreach ($uv_list as &$uv) {
if (!is_array($uv)) {
continue;
}
for ($i = 1; $i < count($uv); $i++) {
if (substr($uv[$i], 0, 6) == 'value:') {
$uv[$i] = PMA_arrayRead(substr($uv[$i], 6), $GLOBALS['PMA_Config']->base_settings);
}
}
}
$validators[$field] = isset($validators[$field]) ? array_merge((array) $validators[$field], $uv_list) : $uv_list;
}
}
}
return $validators;
}
示例2: getOptionValueList
/**
* Returns allowed values for select fields
*
* @param string $option_path Option path
*
* @return array
*/
public function getOptionValueList($option_path)
{
$value = $this->_configFile->getDbEntry($option_path);
if ($value === null) {
trigger_error("{$option_path} - select options not defined", E_USER_ERROR);
return array();
}
if (!is_array($value)) {
trigger_error("{$option_path} - not a static value list", E_USER_ERROR);
return array();
}
// convert array('#', 'a', 'b') to array('a', 'b')
if (isset($value[0]) && $value[0] === '#') {
// remove first element ('#')
array_shift($value);
// $value has keys and value names, return it
return $value;
}
// convert value list array('a', 'b') to array('a' => 'a', 'b' => 'b')
$has_string_keys = false;
$keys = array();
for ($i = 0, $nb = count($value); $i < $nb; $i++) {
if (!isset($value[$i])) {
$has_string_keys = true;
break;
}
$keys[] = is_bool($value[$i]) ? (int) $value[$i] : $value[$i];
}
if (!$has_string_keys) {
$value = array_combine($keys, $value);
}
// $value has keys and value names, return it
return $value;
}
示例3: testGetDbEntry
/**
* Test for ConfigFile::getDbEntry
*
* @return void
* @test
*/
public function testGetDbEntry()
{
$cfg_db = array();
include './libraries/config.values.php';
// verify that $cfg_db read from config.values.php is valid
$this->assertGreaterThanOrEqual(20, count($cfg_db));
$this->assertEquals($cfg_db['Servers'][1]['port'], $this->object->getDbEntry('Servers/1/port'));
$this->assertNull($this->object->getDbEntry('no such key'));
$this->assertEquals(array(1), $this->object->getDbEntry('no such key', array(1)));
}