Skip to main content
edited body
Source Link
dwcdev
  • 171
  • 4

Drupal 7 doesn't use the '%' place holders. Try this:

$primary_key = db_query("SELECT 'COLUMN_NAME'`COLUMN_NAME` FROM 'information_schema'`information_schema`.'COLUMNS'`COLUMNS` WHERE ('TABLE_SCHEMA'`TABLE_SCHEMA` = 'mydatabase') AND ('TABLE_NAME'`TABLE_NAME` = :tbl_name) AND ('COLUMN_KEY'`COLUMN_KEY` = 'PRI')", array(':tbl_name' => $mytable));

Drupal 7 doesn't use the '%' place holders. Try this:

$primary_key = db_query("SELECT 'COLUMN_NAME' FROM 'information_schema'.'COLUMNS' WHERE ('TABLE_SCHEMA' = 'mydatabase') AND ('TABLE_NAME' = :tbl_name) AND ('COLUMN_KEY' = 'PRI')", array(':tbl_name' => $mytable));

Drupal 7 doesn't use the '%' place holders. Try this:

$primary_key = db_query("SELECT `COLUMN_NAME` FROM `information_schema`.`COLUMNS` WHERE (`TABLE_SCHEMA` = 'mydatabase') AND (`TABLE_NAME` = :tbl_name) AND (`COLUMN_KEY` = 'PRI')", array(':tbl_name' => $mytable));
Source Link
dwcdev
  • 171
  • 4

Drupal 7 doesn't use the '%' place holders. Try this:

$primary_key = db_query("SELECT 'COLUMN_NAME' FROM 'information_schema'.'COLUMNS' WHERE ('TABLE_SCHEMA' = 'mydatabase') AND ('TABLE_NAME' = :tbl_name) AND ('COLUMN_KEY' = 'PRI')", array(':tbl_name' => $mytable));