geo/db/mysql_spatial.inc, line 108
- Versions
- 6
geo_mysql_spatial_tables($exclude = NULL)
Return a list of fields, keyed by table, of geo tables.
Parameters
$table an optional string of the table name to look in
Return value
array an array of fields, keyed by table
Code
<?php
function geo_mysql_spatial_tables($exclude = NULL) {
static $tables;
if (!is_array($tables)) {
$tables = array();
// Query for all available geometry columns.
// @@@ Mysql5 + only.
$res = db_query("SELECT TABLE_NAME AS 'table', COLUMN_NAME AS 'field'
FROM information_schema.columns
WHERE TABLE_SCHEMA = database()
AND DATA_TYPE IN ('GEOMETRY','POINT','LINESTRING','POLYGON','MULTIPOINT',
'MULTILINESTRING','MULTIPOLYGON','GEOMETRYCOLLECTION')
ORDER BY TABLE_NAME, COLUMN_NAME");
while ($row = db_fetch_object($res)) {
// Ignore exclusions.
if ($exclude && preg_match($exclude, $row->table)) continue;
if (!isset($tables[$row->table])) {
$tables[$row->table] = array();
}
$tables[$row->table][] = $row->field;
}
}
return $tables;
}
?> 