/** * constructor * * @param array $config * @param array $options */ public function __construct($config, $options = array()) { $config = new Charcoal_HashMap($config); // 接続情報を取得 $backend = $config->getString('backend'); $server = $config->getString('server'); $user = $config->getString('user'); $password = $config->getString('password'); $db_name = $config->getString('db_name'); $port = $config->getString('port'); $charset = $config->getString('charset'); //ad($config->getAll()); // PDOオブジェクトを作成 $dsn = "{$backend}:host={$server};{$port}dbname={$db_name};charset={$charset};"; //echo "DSN:$dsn" . PHP_EOL; $default_options = array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_EMULATE_PREPARES => false); $options = array_merge($default_options, $options); parent::__construct($dsn, $user, $password, $options); }
/** * arrayをHashMapオブジェクトに変換 **/ function m($value) { if ($value instanceof Charcoal_HashMap) { return $value; } return $value !== NULL ? new Charcoal_HashMap($value) : Charcoal_HashMap::defaultValue(); }
/** * Get element value as file size * * @param string $key Key string to get * @param string $default_value default value * * @return integer */ public function getSize($key, $default_value = NULL) { // Charcoal_ParamTrait::validateString( 1, $key ); // Charcoal_ParamTrait::validateString( 2, $default_value, TRUE ); $key = us($key); $value = parent::getString($key, $default_value); return Charcoal_MemoryUtil::getByteSizeFromString($value); }
/** * Get element value as float * * @param string $key Key string to get * @param float $default_value default value * * @return float */ public function getFloat($key, $default_value = NULL) { // Charcoal_ParamTrait::validateString( 1, $key ); $key = us($key); return parent::getFloat($key, $default_value); }