tags:

views:

446

answers:

2

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.

A: 

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.

foreach( $columns as $field ) { 
 $upperfname = strtoupper($field->name);
 if (adodb_key_exists($upperfname,$arrFields,$force)) {
  $bad = false;
  if ((strpos($upperfname,' ') !== false) || ($ADODB_QUOTE_FIELDNAMES))
   $fnameq = $zthis->nameQuote.$upperfname.$zthis->nameQuote;
  else
   $fnameq = $upperfname;
    ...
  // Get the name of the fields to insert
  $fields .= $fnameq . ", ";
    }
}

I haven't tested it, but it seems like you could change the last line to this:

$fields .= strtolower($fnameq) . ", ";

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.

Jonathan Campbell
A: 

Depends on the database, really.

For Oracle, you can do:

define('ADODB_ASSOC_CASE', 0);
$db = NewADOConnection('oci8po');

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"