Expand php pdo to support impala, but the setAttribute() function failed. My code is:
class ImpalaPDO extends PDO {
public function __construct($dsn, $username, $passwd, $options)
{
parent::__construct($dsn, $username, $passwd, $options);
$impala = new ImpalaPDOStatement();
$impala->test();
$this->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('ImpalaPDOStatement', array($this)));
}
}
class ImpalaPDOStatement extends PDOStatement {
public function test() {
print "aaa";
}
}
The error message is: SQLSTATE[HY000]: General error: PDO::ATTR_STATEMENT_CLASS requires format array(classname, array(ctor_args)); the classname must be a string specifying an existing class. What I can confirm is ImpalaPDOStatement is existing, because $impala->test() print a string successfully. So I don't know what the error message mean.
You must override protected constructor of PDOStatement
:
class ImpalaPDOStatement extends PDOStatement {
public $dbh;
// Constructor must be overrided
protected function __construct($dbh) {
$this->dbh = $dbh;
}
public function test() {
print "aaa";
}
}