如何强制 adodb php 库使用小写字段名称
我正在尝试在我的网络应用程序中使用 adodb 进行数据库访问。 然而我的托管提供商对 mysql 区分大小写, 我的所有字段都是小写的。 但是当我调用 getInsertSQL 函数时, 我把它们改成了大写。
有没有办法强制adodb使用小写?
我尝试过
define('ADODB_ASSOC_CASE', 0);
$ADODB_ASSOC_CASE = 0;
但它似乎被忽略了,因为该常量应该只用于 oracle、MSSQL 和其他 DBMS
$conn = &ADONewConnection($this->DbType);
$conn = PConnect($dbServer,$dbUser, $dbPassword,$database);
$tableName = "sample";
$insertSQL = $conn->GetInsertSQL($tableName,$objDB);
我得到了列名大写的 SQL 语句。
I'm trying to use adodb for db access in my webapp.
However my hosting provider has mysql case sensitive,
and I have all my fields in lowercase. But when I call getInsertSQL function,
I got them in uppercase.
Is there a way to force adodb to use lowercase?
I tried with
define('ADODB_ASSOC_CASE', 0);
$ADODB_ASSOC_CASE = 0;
But it seems to be ignored as the constant is suppose to be used only with oracle, MSSQL and other DBMS
$conn = &ADONewConnection($this->DbType);
$conn = PConnect($dbServer,$dbUser, $dbPassword,$database);
$tableName = "sample";
$insertSQL = $conn->GetInsertSQL($tableName,$objDB);
And I got the SQL statement with the column names in uppercase.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
开箱即用的 adodb 不提供此选项。 我下载了最新版本,它强制 GetInsertSQL 中的所有列名称(对于所有驱动程序)均为大写。
我还没有测试过它,但似乎您可以将最后一行更改为:
请注意,如果您稍后更新到较新版本的 adodb,则必须再次进行此更改。 由于区分大小写的表名和列名是 MySQL 中的一个选项,因此您可能还想建议 adodb 的开发人员将其添加为选项。
Out of the box adodb doesn't give you this option. I downloaded the latest version and it forces all column names (for all drivers) in GetInsertSQL to be uppercase.
I haven't tested it, but it seems like you could change the last line to this:
Just be aware that, if you update to a newer version of adodb later, you'll have to make this change again. Since case sensitive table names and column names is an option in MySQL, you may also want to suggest to the developers of adodb that they add this as an option.
实际上取决于数据库。
对于 Oracle,您可以这样做:
oci8po 应该比普通的 oci8 慢,但我没有注意到差异。 它允许小写列名以及“?” 绑定参数而不是“:column”
Depends on the database, really.
For Oracle, you can do:
The oci8po is supposed to be slower than the normal oci8, but I haven't noticed a difference. It allows both lowercase column names as well as "?" bind parameters as opposed to ":column"