geo_backend_type

geo/geo.inc, line 8

Versions
6
geo_backend_type()

Return the geo backend database type.

Return value

string The name of the backend: postgis, cck, mysql_spatial

▾ 2 functions call geo_backend_type()

geo in geo/geo.module
Call an API function from the geo backend databases. This function will find and load the database backend files, and call the requested op from the backend or the default library, as needed.
geo in geo/geo.module
Call an API function from the geo backend databases. This function will find and load the database backend files, and call the requested op from the backend or the default library, as needed.

Code

<?php
function geo_backend_type() {
  static $backend;

  if (!isset($backend)) {
    switch ($GLOBALS['db_type']) {
      case 'pgsql':
        // use the postgis backend if installed
        if (db_result(db_query("SELECT 1 FROM pg_catalog.pg_proc 
          WHERE proname = 'postgis_version'"))) {
          $backend = 'postgis';
        }
        break;

      case 'mysql':
      case 'mysqli':
        // Capabilities check.
        // If it can convert between native and wkt, assume it's working.
        if (db_result(@db_query("SELECT AsText(GeomFromText('POINT(1 1)'))")) == 'POINT(1 1)') {
          $backend = 'mysql_spatial';
        }
    }
  }

  return $backend;
}
?>