如何使用 Oracle 模拟 PDO::getColumnData()



我有一个普通的PHP 7应用程序,它(旨在(支持MySQL,Postgres,SQL Server和Oracle。

我现在遇到了一个问题,因为除了 Oracle (pdo_oci( 之外,其他都支持 getColumnData((

$statement   = $pdo->query('SELECT titulo, preco FROM livro');
$metadados   = $statement->getColumnMeta(0);

MySQL:

array(7) { ["native_type"]=> string(10) "VAR_STRING" ["pdo_type"]=> int(2) ["flags"]=> array(1) { [0]=> string(8) "not_null" } ["table"]=> string(5) "livro" ["name"]=> string(6) "titulo" ["len"]=> int(765) ["precision"]=> int(0) } 

邮政:

array(8) { ["pgsql:oid"]=> int(1043) ["pgsql:table_oid"]=> int(16585) ["table"]=> string(5) "livro" ["native_type"]=> string(7) "varchar" ["name"]=> string(6) "titulo" ["len"]=> int(-1) ["precision"]=> int(259) ["pdo_type"]=> int(2) } 

SQLServer:

array(8) { ["flags"]=> int(0) ["sqlsrv:decl_type"]=> string(7) "varchar" ["native_type"]=> string(6) "string" ["table"]=> string(0) "" ["pdo_type"]=> int(2) ["name"]=> string(6) "titulo" ["len"]=> int(255) ["precision"]=> int(0) }

有没有办法模拟其他驱动程序的类似结果,但使用pdo_oci?

PHP 7.4 为此添加了对PDO_OCI的支持:bugs.php.net/bug.php?id=76908

最新更新