php - Modifying / Adding extra stuff to PDO bindParam()? -


does know chance if there clean way (or way @ all) change pdo's bindparam?

we're implementing security measures our websites (filters inputs) , far seems best way add every single website have efficiently (every website have different thing have in common use pdo) somehow make pdo bindparam call our function on it's parameters, every single input in bindparam filtered appropriately.

thanks!

solved extending pdo classes:

class customdbconnection {      private static $conn;      // either create new connection or return existing 1     public static function getinstance() {         if (self::$conn == null) {             global $db_hostname, $db_database, $db_username, $db_password; // better store these within class quicker             self::$conn = new custompdo("mysql:host=$db_hostname;dbname=$db_database;charset=utf8", $db_username, $db_password, array(pdo::attr_emulate_prepares => false, pdo::attr_errmode => pdo::errmode_exception));         }          return self::$conn;     } }  class custompdo extends pdo {      public function __construct($dsn, $username = null, $password = null, $driver_options = array()) {          parent::__construct($dsn, $username, $password, $driver_options);          // attach customised pdostatement class         $this->setattribute(pdo::attr_statement_class, array('custompdostatement', array($this)));     } }  class custompdostatement extends pdostatement {      private $conn;      protected function __construct($conn) {         $this->conn = $conn; // useless @ moment     }      public function bindparam($parameter, &$variable, $data_type = pdo::param_str, $length = null, $driver_options = null) {         $variable = inputprotection::detachevilhtml($variable);          parent::bindparam($parameter, $variable, $data_type, $length, $driver_options);     }      public function bindvalue($parameter, $value, $data_type = pdo::param_str) {         $value = inputprotection::detachevilhtml($value);          parent::bindvalue($parameter, $value, $data_type);     } } 

so $db = customdbconnection::getinstance(); instead of $db = new pdo(.......);


Comments

Popular posts from this blog

gridview - Yii2 DataPorivider $totalSum for a column -

java - Suppress Jboss version details from HTTP error response -

Sass watch command compiles .scss files before full sftp upload -