<?php
namespace App\Service;
class PDO extends \PDO {
const PARAM_ARRAY_INT = 11;
const PARAM_ARRAY_STR = 12;
const PARAM_ARRAY_LOB = 13;
const PARAM_ARRAY_BOOL = 15;
protected $driver_options;
public function __construct (string $dsn = "", string $username = "", string $passwd = "", array $options = [] ) {
parent::__construct($dsn, $username, $passwd);
}
/**
*
* @param string $statement
* @param array $driver_options
*/
public function prepare($statement, $driver_options = array()) {
$this->driver_options = $driver_options;
return new PDOStatement($statement, $this);
}
public function nativePrepare ($statement) {
return parent::prepare($statement, $this->driver_options);
}
public function isArrayType($type) {
return
$type === self::PARAM_ARRAY_INT ||
$type === self::PARAM_ARRAY_STR ||
$type === self::PARAM_ARRAY_LOB ||
$type === self::PARAM_ARRAY_BOOL;
}
public function arrayTypeToNativeType($arrayType) {
switch($arrayType) {
case self::PARAM_ARRAY_INT:
return self::PARAM_INT;
case self::PARAM_ARRAY_STR:
return self::PARAM_STR;
case self::PARAM_ARRAY_LOB:
return self::PARAM_LOB;
case self::PARAM_ARRAY_BOOL:
return self::PARAM_BOOL;
default:
throw new \InvalidArgumentException('Unknown type: ' . $arrayType);
}
}
}