src/Service/PDO.php line 23

Open in your IDE?
  1. <?php
  2. namespace App\Service;
  3. class PDO extends \PDO {
  4.     
  5.     const PARAM_ARRAY_INT 11;
  6.     const PARAM_ARRAY_STR 12;
  7.     const PARAM_ARRAY_LOB 13;
  8.     const PARAM_ARRAY_BOOL 15;
  9.     
  10.     protected $driver_options;
  11.     
  12.     public function __construct (string $dsn ""string $username ""string $passwd "", array $options = [] ) {
  13.         parent::__construct($dsn$username$passwd);
  14.     }
  15.     /**
  16.      * 
  17.      * @param string $statement
  18.      * @param array $driver_options
  19.      */
  20.     public function prepare($statement$driver_options = array()) {
  21.         $this->driver_options $driver_options;
  22.         return new PDOStatement($statement$this);
  23.     }
  24.     public function nativePrepare ($statement) {
  25.         return parent::prepare($statement$this->driver_options);
  26.     }
  27.     
  28.     public function isArrayType($type) {
  29.         return
  30.                 $type === self::PARAM_ARRAY_INT || 
  31.                 $type === self::PARAM_ARRAY_STR || 
  32.                 $type === self::PARAM_ARRAY_LOB || 
  33.                 $type === self::PARAM_ARRAY_BOOL;
  34.     }
  35.         
  36.     public function arrayTypeToNativeType($arrayType) {
  37.         switch($arrayType) {
  38.             case self::PARAM_ARRAY_INT:
  39.                 return self::PARAM_INT;
  40.             case self::PARAM_ARRAY_STR:
  41.                 return self::PARAM_STR;
  42.             case self::PARAM_ARRAY_LOB:
  43.                 return self::PARAM_LOB;
  44.             case self::PARAM_ARRAY_BOOL:
  45.                 return self::PARAM_BOOL;
  46.             default:
  47.                 throw new \InvalidArgumentException('Unknown type: ' $arrayType);                
  48.         }
  49.     }
  50. }