samedi 1 juin 2019

Why get_class_methods() does not show all methods of a specific PDO driver?

I was trying to get all method for each PDO driver (I have all of them installed on my PC Windows).

But if I try, for example, using Postgres (pdo_pgsql):

var_dump(get_class_methods($pdo));

The result is:

array(17) { [0]=> string(11) "__construct" [1]=> string(7) "prepare" [2]=> string(16) "beginTransaction" [3]=> string(6) "commit" [4]=> string(8) "rollBack" [5]=> string(13) "inTransaction" [6]=> string(12) "setAttribute" [7]=> string(4) "exec" [8]=> string(5) "query" [9]=> string(12) "lastInsertId" [10]=> string(9) "errorCode" [11]=> string(9) "errorInfo" [12]=> string(12) "getAttribute" [13]=> string(5) "quote" [14]=> string(8) "__wakeup" [15]=> string(7) "__sleep" [16]=> string(19) "getAvailableDrivers" } 

But this list is incomplete because PDO Postgres includes methods like:

$pdo->pgsqlCopyToArray('my_table');

Is there a way to get all methods and not only the PDO defaults only?

Thanks in advance, Celso

Edit:

I've tried Reflection too, and the result is incomplete like get_class_methods():

var_dump(array_column((new ReflectionClass($pdo))->getMethods(), 'name'));

The result:

array(17) { [0]=> string(11) "__construct" [1]=> string(7) "prepare" [2]=> string(16) "beginTransaction" [3]=> string(6) "commit" [4]=> string(8) "rollBack" [5]=> string(13) "inTransaction" [6]=> string(12) "setAttribute" [7]=> string(4) "exec" [8]=> string(5) "query" [9]=> string(12) "lastInsertId" [10]=> string(9) "errorCode" [11]=> string(9) "errorInfo" [12]=> string(12) "getAttribute" [13]=> string(5) "quote" [14]=> string(8) "__wakeup" [15]=> string(7) "__sleep" [16]=> string(19) "getAvailableDrivers" } 





Aucun commentaire:

Enregistrer un commentaire