I'm working in a project using mySQL and SQLite DB. My goal is to make the code able to work with both database types. I developed the code for mySQL, using the mysqli
class, and now I want to modify it to make it also work with SQLite3
objects.
SQLite3
class implements the same methods as mysqli
(at least, those than I use), but sometimes using different names. For example, mysqli::fetch_array()
becomes SQLite3::fechArray()
. So I'm extending SQLite3 and SQLite3Result
classes to implement the methods I need. For example:
class SQLite3ResultEx extends SQLite3Result {
public function fetch_array() {
return parent::fetchArray();
}
}
The problem is that I don't know how to do for extending the response for SQLite3
class to get my own SQLite3Response
extended class. I mean:
class SQLite3Ex extends SQLite3 {
public function __construct($filename, $flags = null, $encryption_key = null) {
return parent::__construct($filename, $flags, $encryption_key);
}
public function query($query) {
$res = parent::query($query);
return $res;
}
}
Now $res
is an SQLite3Result
object, but I need it becomes a SQLite3ResultEx
object (my own extended class).