- Patch #137479 by dww: added db_column_exits(). (Yay, the servers are snappy on Saturday evening.)
parent
cf050e5f6e
commit
9050e15621
|
@ -421,6 +421,13 @@ function db_table_exists($table) {
|
|||
return db_num_rows(db_query("SHOW TABLES LIKE '{". db_escape_table($table) ."}'"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a column exists in the given table.
|
||||
*/
|
||||
function db_column_exists($table, $column) {
|
||||
return db_num_rows(db_query("SHOW COLUMNS FROM {%s} LIKE '%s'", $table, $column));
|
||||
}
|
||||
|
||||
/**
|
||||
* Wraps the given table.field entry with a DISTINCT(). The wrapper is added to
|
||||
* the SELECT list entry of the given query and the resulting query is returned.
|
||||
|
|
|
@ -401,6 +401,13 @@ function db_table_exists($table) {
|
|||
return db_num_rows(db_query("SHOW TABLES LIKE '{". db_escape_table($table) ."}'"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a column exists in the given table.
|
||||
*/
|
||||
function db_column_exists($table, $column) {
|
||||
return db_num_rows(db_query("SHOW COLUMNS FROM {%s} LIKE '%s'", $table, $column));
|
||||
}
|
||||
|
||||
/**
|
||||
* Wraps the given table.field entry with a DISTINCT(). The wrapper is added to
|
||||
* the SELECT list entry of the given query and the resulting query is returned.
|
||||
|
|
|
@ -394,6 +394,13 @@ function db_table_exists($table) {
|
|||
return db_num_rows(db_query("SELECT relname FROM pg_class WHERE relname = '{". db_escape_table($table) ."}'"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a column exists in the given table.
|
||||
*/
|
||||
function db_column_exists($table, $column) {
|
||||
return db_result(db_query("SELECT COUNT(pg_attribute.attname) FROM pg_class, pg_attribute WHERE pg_attribute.attrelid = pg_class.oid AND pg_class.relname = '{". db_escape_table($table) ."}' AND attname='%s'", $column));
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if the database is set up correctly.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue