Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

I've mucked to much with PDO and Drupal -- try this it out and let us know :).

The database layer in Drupal uses PDO. You can fetch results to a custom class typically by setting the FETCH_MODE .... welllll I was gonna link you here Fetching into a custom class

But, it looks the answer is more simple but probably doesn't buy you much. But maybe you'll find this helpful. Read on ...

You just need to tell PDO to respect the case semantics of your SQL statement for your queries (trying to do this on all queries in drupal, see below, will probably blow chunks).

Relevent Additional Documentation is here:

I think you'd have to write your queries similar to:

// This gets the default drupal database connection, you can pass parameters to
// select alternate dbs defined in settings.php
$db = Database::getConnection();
// This tells PDO to use the case of the raw SQL statement allowing you to write:
// SELECT foo_bar AS fooBar, some_other_property AS someOtherProperty ...
// and they will return in your fetchObject object as camelCased (natual, whatever you AS'd as case) ...
$db->setAttribute( PDO::ATTR_CASE, PDO::CASE_NATURAL );
// This is the long route of writing db_select('table')->fields() ...
// caveat the db_select->fields() method doesnt allow aliasing, you have to
// add fields to your query via addField()
$query = $db->select('some_table', 'some_table_alias');
// Then add to your select query as needed.
$query->addField('some_table_alias', 'foo_bar', 'fooBar');

Some other notes:

  • Without getting reallllly creative I dont think you can do this using db_query(). db_query() is a simple helper method to the default database connection (not any db) and I'm not sure you can Database::getConnection()->query("...");
  • You could try to set this globally in drupal in your settings.php by using a patch https://drupal.org/node/726192 to allow abritrary PDO attributes to be set on the database connection defined in settings.php. I dont recommend this.

I've mucked to much with PDO and Drupal -- try this it out and let us know :).

The database layer in Drupal uses PDO. You can fetch results to a custom class typically by setting the FETCH_MODE .... welllll I was gonna link you here Fetching into a custom class

But, it looks the answer is more simple but probably doesn't buy you much. But maybe you'll find this helpful. Read on ...

You just need to tell PDO to respect the case semantics of your SQL statement for your queries (trying to do this on all queries in drupal, see below, will probably blow chunks).

Relevent Additional Documentation is here:

I think you'd have to write your queries similar to:

// This gets the default drupal database connection, you can pass parameters to
// select alternate dbs defined in settings.php
$db = Database::getConnection();
// This tells PDO to use the case of the raw SQL statement allowing you to write:
// SELECT foo_bar AS fooBar, some_other_property AS someOtherProperty ...
// and they will return in your fetchObject object as camelCased (natual, whatever you AS'd as case) ...
$db->setAttribute( PDO::ATTR_CASE, PDO::CASE_NATURAL );
// This is the long route of writing db_select('table')->fields() ...
// caveat the db_select->fields() method doesnt allow aliasing, you have to
// add fields to your query via addField()
$query = $db->select('some_table', 'some_table_alias');
// Then add to your select query as needed.
$query->addField('some_table_alias', 'foo_bar', 'fooBar');

Some other notes:

  • Without getting reallllly creative I dont think you can do this using db_query(). db_query() is a simple helper method to the default database connection (not any db) and I'm not sure you can Database::getConnection()->query("...");
  • You could try to set this globally in drupal in your settings.php by using a patch https://drupal.org/node/726192 to allow abritrary PDO attributes to be set on the database connection defined in settings.php. I dont recommend this.

I've mucked to much with PDO and Drupal -- try this it out and let us know :).

The database layer in Drupal uses PDO. You can fetch results to a custom class typically by setting the FETCH_MODE .... welllll I was gonna link you here Fetching into a custom class

But, it looks the answer is more simple but probably doesn't buy you much. But maybe you'll find this helpful. Read on ...

You just need to tell PDO to respect the case semantics of your SQL statement for your queries (trying to do this on all queries in drupal, see below, will probably blow chunks).

Relevent Additional Documentation is here:

I think you'd have to write your queries similar to:

// This gets the default drupal database connection, you can pass parameters to
// select alternate dbs defined in settings.php
$db = Database::getConnection();
// This tells PDO to use the case of the raw SQL statement allowing you to write:
// SELECT foo_bar AS fooBar, some_other_property AS someOtherProperty ...
// and they will return in your fetchObject object as camelCased (natual, whatever you AS'd as case) ...
$db->setAttribute( PDO::ATTR_CASE, PDO::CASE_NATURAL );
// This is the long route of writing db_select('table')->fields() ...
// caveat the db_select->fields() method doesnt allow aliasing, you have to
// add fields to your query via addField()
$query = $db->select('some_table', 'some_table_alias');
// Then add to your select query as needed.
$query->addField('some_table_alias', 'foo_bar', 'fooBar');

Some other notes:

  • Without getting reallllly creative I dont think you can do this using db_query(). db_query() is a simple helper method to the default database connection (not any db) and I'm not sure you can Database::getConnection()->query("...");
  • You could try to set this globally in drupal in your settings.php by using a patch https://drupal.org/node/726192 to allow abritrary PDO attributes to be set on the database connection defined in settings.php. I dont recommend this.
replaced http://drupal.stackexchange.com/ with https://drupal.stackexchange.com/
Source Link

I've mucked to much with PDO and Drupal -- try this it out and let us know :).

The database layer in Drupal uses PDO. You can fetch results to a custom class typically by setting the FETCH_MODE .... welllll I was gonna link you here Fetching into a custom class

But, it looks the answer is more simple but probably doesn't buy you much. But maybe you'll find this helpful. Read on ...

You just need to tell PDO to respect the case semantics of your SQL statement for your queries (trying to do this on all queries in drupal, see below, will probably blow chunks).

Relevent Additional Documentation is here:

I think you'd have to write your queries similar to:

// This gets the default drupal database connection, you can pass parameters to
// select alternate dbs defined in settings.php
$db = Database::getConnection();
// This tells PDO to use the case of the raw SQL statement allowing you to write:
// SELECT foo_bar AS fooBar, some_other_property AS someOtherProperty ...
// and they will return in your fetchObject object as camelCased (natual, whatever you AS'd as case) ...
$db->setAttribute( PDO::ATTR_CASE, PDO::CASE_NATURAL );
// This is the long route of writing db_select('table')->fields() ...
// caveat the db_select->fields() method doesnt allow aliasing, you have to
// add fields to your query via addField()
$query = $db->select('some_table', 'some_table_alias');
// Then add to your select query as needed.
$query->addField('some_table_alias', 'foo_bar', 'fooBar');

Some other notes:

  • Without getting reallllly creative I dont think you can do this using db_query(). db_query() is a simple helper method to the default database connection (not any db) and I'm not sure you can Database::getConnection()->query("...");
  • You could try to set this globally in drupal in your settings.php by using a patch https://drupal.org/node/726192 to allow abritrary PDO attributes to be set on the database connection defined in settings.php. I dont recommend this.

I've mucked to much with PDO and Drupal -- try this it out and let us know :).

The database layer in Drupal uses PDO. You can fetch results to a custom class typically by setting the FETCH_MODE .... welllll I was gonna link you here Fetching into a custom class

But, it looks the answer is more simple but probably doesn't buy you much. But maybe you'll find this helpful. Read on ...

You just need to tell PDO to respect the case semantics of your SQL statement for your queries (trying to do this on all queries in drupal, see below, will probably blow chunks).

Relevent Additional Documentation is here:

I think you'd have to write your queries similar to:

// This gets the default drupal database connection, you can pass parameters to
// select alternate dbs defined in settings.php
$db = Database::getConnection();
// This tells PDO to use the case of the raw SQL statement allowing you to write:
// SELECT foo_bar AS fooBar, some_other_property AS someOtherProperty ...
// and they will return in your fetchObject object as camelCased (natual, whatever you AS'd as case) ...
$db->setAttribute( PDO::ATTR_CASE, PDO::CASE_NATURAL );
// This is the long route of writing db_select('table')->fields() ...
// caveat the db_select->fields() method doesnt allow aliasing, you have to
// add fields to your query via addField()
$query = $db->select('some_table', 'some_table_alias');
// Then add to your select query as needed.
$query->addField('some_table_alias', 'foo_bar', 'fooBar');

Some other notes:

  • Without getting reallllly creative I dont think you can do this using db_query(). db_query() is a simple helper method to the default database connection (not any db) and I'm not sure you can Database::getConnection()->query("...");
  • You could try to set this globally in drupal in your settings.php by using a patch https://drupal.org/node/726192 to allow abritrary PDO attributes to be set on the database connection defined in settings.php. I dont recommend this.

I've mucked to much with PDO and Drupal -- try this it out and let us know :).

The database layer in Drupal uses PDO. You can fetch results to a custom class typically by setting the FETCH_MODE .... welllll I was gonna link you here Fetching into a custom class

But, it looks the answer is more simple but probably doesn't buy you much. But maybe you'll find this helpful. Read on ...

You just need to tell PDO to respect the case semantics of your SQL statement for your queries (trying to do this on all queries in drupal, see below, will probably blow chunks).

Relevent Additional Documentation is here:

I think you'd have to write your queries similar to:

// This gets the default drupal database connection, you can pass parameters to
// select alternate dbs defined in settings.php
$db = Database::getConnection();
// This tells PDO to use the case of the raw SQL statement allowing you to write:
// SELECT foo_bar AS fooBar, some_other_property AS someOtherProperty ...
// and they will return in your fetchObject object as camelCased (natual, whatever you AS'd as case) ...
$db->setAttribute( PDO::ATTR_CASE, PDO::CASE_NATURAL );
// This is the long route of writing db_select('table')->fields() ...
// caveat the db_select->fields() method doesnt allow aliasing, you have to
// add fields to your query via addField()
$query = $db->select('some_table', 'some_table_alias');
// Then add to your select query as needed.
$query->addField('some_table_alias', 'foo_bar', 'fooBar');

Some other notes:

  • Without getting reallllly creative I dont think you can do this using db_query(). db_query() is a simple helper method to the default database connection (not any db) and I'm not sure you can Database::getConnection()->query("...");
  • You could try to set this globally in drupal in your settings.php by using a patch https://drupal.org/node/726192 to allow abritrary PDO attributes to be set on the database connection defined in settings.php. I dont recommend this.
Source Link
tenken
  • 18.4k
  • 2
  • 39
  • 57

I've mucked to much with PDO and Drupal -- try this it out and let us know :).

The database layer in Drupal uses PDO. You can fetch results to a custom class typically by setting the FETCH_MODE .... welllll I was gonna link you here Fetching into a custom class

But, it looks the answer is more simple but probably doesn't buy you much. But maybe you'll find this helpful. Read on ...

You just need to tell PDO to respect the case semantics of your SQL statement for your queries (trying to do this on all queries in drupal, see below, will probably blow chunks).

Relevent Additional Documentation is here:

I think you'd have to write your queries similar to:

// This gets the default drupal database connection, you can pass parameters to
// select alternate dbs defined in settings.php
$db = Database::getConnection();
// This tells PDO to use the case of the raw SQL statement allowing you to write:
// SELECT foo_bar AS fooBar, some_other_property AS someOtherProperty ...
// and they will return in your fetchObject object as camelCased (natual, whatever you AS'd as case) ...
$db->setAttribute( PDO::ATTR_CASE, PDO::CASE_NATURAL );
// This is the long route of writing db_select('table')->fields() ...
// caveat the db_select->fields() method doesnt allow aliasing, you have to
// add fields to your query via addField()
$query = $db->select('some_table', 'some_table_alias');
// Then add to your select query as needed.
$query->addField('some_table_alias', 'foo_bar', 'fooBar');

Some other notes:

  • Without getting reallllly creative I dont think you can do this using db_query(). db_query() is a simple helper method to the default database connection (not any db) and I'm not sure you can Database::getConnection()->query("...");
  • You could try to set this globally in drupal in your settings.php by using a patch https://drupal.org/node/726192 to allow abritrary PDO attributes to be set on the database connection defined in settings.php. I dont recommend this.