| TerraLib 4.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Examples

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Friends
TeMySQL Class Reference

A concrete implementation of a driver to the MySQL SGDB. More...

`#include <TeMySQL.h>`

Inheritance diagram for TeMySQL:

List of all members.

## Public Member Functions

| TeMySQL ()
| ~TeMySQL ()
st_mysql * | getMySQL ()
string | escapeSequence (const string &from)
| Escape special characters in a string to be used in a SQL statement.
bool | newDatabase (const string &database, const string &user, const string &password, const string &host, const int &port=-1, bool terralibModel=true, const std::string &characterSet="")
| Creates a new database and open a connection to it.
bool | connect (const string &host, const string &user, const string &password, const string &database, int port=-1)
| Opens a connection to a database server passing all parameters needed.
bool | showDatabases (const string &host, const string &user, const string &password, vector< string > &dbNames, int port=-1)
| Show the server databases (only for MySQL, Oracle and PostgreSQL)
void | close ()
| Closes the connection.
virtual bool | listDatabases (std::vector< std::string > &databaseList)
| Returns a lista of databases.
virtual bool | dropDatabase (const std::string &databaseName)
| Drop a database.
bool | tableExist (const string &table)
| Verifies if a table exist in the database.
bool | columnExist (const string &table, const string &column, TeAttribute &attr)
| Verifies if a table has a column.
bool | addColumn (const string &table, TeAttributeRep &rep)
| Adds a column to a table.
virtual bool | deleteIndex (const string &tableName, const string &indexName)
| Delete the index from tables in the conceptual model.
virtual bool | getIndexesFromTable (const string &tableName, std::vector< TeDatabaseIndex > &vecIndexes)
| Return a TeDatabaseIndex vector from a table.
virtual bool | alterTable (const string &tableName, TeAttributeRep &rep, const string &oldColName="")
| Alter a property of a table.
bool | defineIntegrity (void)
| Creates the referencial integrity of the conceptual model.
bool | createRelation (const string &, const string &, const string &, const string &, const string &, bool)
| Creates a reationship between two tables.
TeDBRelationType | existRelation (const string &, const string &)
| Checks if a relation exist.
bool | execute (const string &q)
| Executes a SQL command that doesnt return a record set. Tipically a data definition comand.
bool | createTable (const string &table, TeAttributeList &attr)
| Creates a table.
TeDatabasePortal * | getPortal ()
| Returns a database portal.
string | errorMessage ()
| Returns the error message from the server.
int | errorNum ()
| Returns the error number from the server.
bool | insertProjection (TeProjection *proj)
| Insert information about a geographical projection.
bool | insertLayer (TeLayer *layer)
| Insert information about a layer.
bool | insertProject (TeProject *project)
| Insert information about a project.
bool | insertRepresentation (int layerId, TeRepresentation &rep)
| Inserts information about a geometrical representation.
bool | insertTable (TeTable &table)
| Saves a table and its contents in the database.
bool | updateTable (TeTable &table)
| Updates a table and its contents in the database.
bool | insertTableInfo (int layerId, TeTable &table, const string &user="")
| Inserts information about an attribute table.
bool | insertRelationInfo (const int tableId, const string &tField, const string &eTable, const string &eField, int &relId)
| Inserts information about a link to an external table.
bool | insertView (TeView *view)
| Inserts a view.
bool | insertViewTree (TeViewTree *tree)
| Recursive inserting of a view tree.
bool | insertTheme (TeAbstractTheme *theme)
| Inserts an abstract theme in the database.
bool | insertThemeGroup (TeViewTree *tree)
| Inserts a group of themes in the database.
bool | generateLabelPositions (TeTheme *theme, const std::string &objectId="")
| Generates the label position (x,y) to each object of a theme or of a particular object.
bool | insertThemeTable (int themeId, int tableId, int relationId, int tableOrder)
| Inserts information about a table used by a theme.
bool | insertLegend (TeLegendEntry *legend)
| Inserts legend in the database.
bool | insertPolygon (const string &table, TePolygon &p)
| Inserts a polygon in a geometry table.
bool | insertPolygonSet (const string &table, TePolygonSet &ps)
| Inserts a polygon set in a geometry table.
bool | updatePolygon (const string &table, TePolygon &p)
| Updates a polygon in a geometry table.
bool | insertLineSet (const string &table, TeLineSet &ls)
bool | insertLine (const string &table, TeLine2D &l)
bool | updateLine (const string &table, TeLine2D &l)
bool | insertPoint (const string &table, TePoint &p)
bool | insertText (const string &table, TeText &t)
bool | insertArc (const string &table, TeArc &arc)
| Inserts an arc geometry in the database.
bool | insertNode (const string &table, TeNode &node)
bool | insertCell (const string &table, TeCell &c)
int | insertId ()
bool | insertRasterBlock (const string &table, const string &blockId, const TeCoord2D &ll, const TeCoord2D &ur, unsigned char *buf, unsigned long size, int band=0, unsigned int res=1, unsigned int subband=0)
| Insert a raster block into the database.
string | getSQLTime (const TeTime &time) const
| Returns a valid SQL time string.
string | getSQLTemporalWhere (int time1, int time2, TeChronon chr, TeTemporalRelation rel, const string &initialTime, const string &finalTime)
| Return a string SQL to temporal where.
bool | inClauseValues (const string &query, const string &attribute, vector< string > &inClauseVector)
| Get the values that satisfy the query.
bool | insertBlob (const string &tableName, const string &columnBlob, const string &whereClause, unsigned char *data, int size)
| Saves a large binary objects (BLOB) in a row table.
string | concatValues (vector< string > &values, const string &unionString)
| Concat values in a vector using unionString as the join between each value.
string | toUpper (const string &value)
| Returns the SQL function for upper case.
string | getConcatFieldsExpression (const vector< string > &fNamesVec)
| Concatenate field values.
bool | beginTransaction ()
| Begins a transaction.
bool | commitTransaction ()
| Commits a transaction.
bool | rollbackTransaction ()
| Rollbacks a transaction.
virtual std::string | getClientEncoding ()
| Gets the client encoding.
virtual bool | setClientEncoding (const std::string &characterSet)
| Sets the client encoding.
virtual bool | getEncodingList (std::vector< std::string > &vecEncodingList)
| Retrives the list of available character sets.
virtual bool | getEncodingList (const std::string &host, const std::string &user, const std::string &password, const int &port, std::vector< std::string > &vecEncodingList)
| Retrives the list of available character sets.

## Friends

class | TeMySQLPortal

## Detailed Description

A concrete implementation of a driver to the MySQL SGDB.

Examples:

  addGeomRepresentation.cpp, copyLayer.cpp, createDatabase.cpp, createLayer.cpp, createProximityMatrix.cpp, createSTElementSetFromLayer.cpp, createSTElementSetFromTheme.cpp, createTable.cpp, createTheme.cpp, databaseQuery.cpp, databaseSQLQuery.cpp, importDBF.cpp, importGeoTab.cpp, importGridData.cpp, importJPEG.cpp, importMIDMIF.cpp, importShape.cpp, proxMatrixAndSpatialStatistics.cpp, querierFromLayer.cpp, querierFromTheme.cpp, querierGroupChronon.cpp, querierGroupElement.cpp, querierGroupSpatialRest.cpp, querierWithSpatialRestBox.cpp, querierWithSpatialRestGeometry.cpp, rasterSlicing.cpp, spatialQuery.cpp, spatialQueryAndBuffer.cpp, and themeGrouping.cpp.

## Constructor & Destructor Documentation

TeMySQL::TeMySQL | ( |  | ) |

TeMySQL::~TeMySQL | ( |  | ) |

## Member Function Documentation

bool TeMySQL::addColumn | ( | const string & | table,
|  | TeAttributeRep & | rep
| ) |  | `[virtual]`

Adds a column to a table.

Parameters:

  table | table name
  rep | representation of the column being created

Implements TeDatabase.

bool TeMySQL::alterTable | ( | const string & | tableName,
|  | TeAttributeRep & | rep,
|  | const string & | oldColName = `""`
| ) |  | `[virtual]`

Alter a property of a table.

Reimplemented from TeDatabase.

bool TeMySQL::beginTransaction | ( |  | ) | `[virtual]`

Begins a transaction.

Reimplemented from TeDatabase.

void TeMySQL::close | ( |  | ) | `[virtual]`

Closes the connection.

Implements TeDatabase.

Examples:
  importShape.cpp.

bool TeMySQL::columnExist | ( | const string & | table,
|  | const string & | column,
|  | TeAttribute & | attr
| ) |  | `[virtual]`

Verifies if a table has a column.

Implements TeDatabase.

bool TeMySQL::commitTransaction | ( |  | ) | `[virtual]`

Commits a transaction.

Reimplemented from TeDatabase.

string TeMySQL::concatValues | ( | vector< string > & | values,
|  | const string & | unionString
| ) |  | `[virtual]`

Concat values in a vector using unionString as the join between each value.

Implements TeDatabase.

bool TeMySQL::connect | ( | const string & | host,
|  | const string & | user,
|  | const string & | password,
|  | const string & | database,
|  | int | port = `-1`
| ) |  | `[virtual]`

Opens a connection to a database server passing all parameters needed.

Implements TeDatabase.

Examples:
  importShape.cpp.

bool TeMySQL::createRelation | ( | const string & | relName,
|  | const string & | table,
|  | const string & | fieldName,
|  | const string & | relatedTable,
|  | const string & | relatedField,
|  | bool | cascadeDeletion
| ) |  | `[inline, virtual]`

Creates a reationship between two tables.

Parameters:

  relName | relationship name
  table | table that will receive the foreign key
  fieldName | column that will be foreign key
  relatedTable | table that exports the foreign key
  relatedField | field that will the exported foreign key
  cascadeDeletion | flag that indicates if the deletion should be propagated

Implements TeDatabase.

bool TeMySQL::createTable | ( | const string & | table,
|  | TeAttributeList & | attr
| ) |  | `[virtual]`

Creates a table.

Parameters:

  table | table name
  attr | table list of attributes

Implements TeDatabase.

bool TeMySQL::defineIntegrity | ( | void |  | ) | `[virtual]`

Creates the referencial integrity of the conceptual model.

Reimplemented from TeDatabase.

bool TeMySQL::deleteIndex | ( | const string & | tableName,
|  | const string & | indexName
| ) |  | `[virtual]`

Delete the index from tables in the conceptual model.

Reimplemented from TeDatabase.

bool TeMySQL::dropDatabase | ( | const std::string & | databaseName | ) | `[virtual]`

Drop a database.

Reimplemented from TeDatabase.

string TeMySQL::errorMessage | ( |  | ) | `[virtual]`

Returns the error message from the server.

Reimplemented from TeDatabase.

Examples:
  importShape.cpp.

int TeMySQL::errorNum | ( |  | ) | `[virtual]`

Returns the error number from the server.

Reimplemented from TeDatabase.

string TeMySQL::escapeSequence | ( | const string & | from | ) | `[virtual]`

Escape special characters in a string to be used in a SQL statement.

Implements TeDatabase.

bool TeMySQL::execute | ( | const string & | sql | ) | `[virtual]`

Executes a SQL command that doesnt return a record set. Tipically a data definition comand.

Implements TeDatabase.

TeDBRelationType TeMySQL::existRelation | ( | const string & | tableName,
|  | const string & | relName
| ) |  | `[inline, virtual]`

Checks if a relation exist.

Parameters:

  tableName | table where the relashionship exists
  relName | relationship name

Implements TeDatabase.

bool TeMySQL::generateLabelPositions | ( | TeTheme * | theme,
|  | const std::string & | objectId = `""`
| ) |  | `[virtual]`

Generates the label position (x,y) to each object of a theme or of a particular object.

Reimplemented from TeDatabase.

std::string TeMySQL::getClientEncoding | ( |  | ) | `[virtual]`

Gets the client encoding.

Reimplemented from TeDatabase.

string TeMySQL::getConcatFieldsExpression | ( | const vector< string > & | fNamesVec | ) | `[virtual]`

Concatenate field values.

Parameters:

  fNamesVec | vector containing the fields to be concatenated

Reimplemented from TeDatabase.

bool TeMySQL::getEncodingList | ( | const std::string & | host,
|  | const std::string & | user,
|  | const std::string & | password,
|  | const int & | port,
|  | std::vector< std::string > & | vecEncodingList
| ) |  | `[virtual]`

Retrives the list of available character sets.

Reimplemented from TeDatabase.

bool TeMySQL::getEncodingList | ( | std::vector< std::string > & | vecEncodingList | ) | `[virtual]`

Retrives the list of available character sets.

Reimplemented from TeDatabase.

bool TeMySQL::getIndexesFromTable | ( | const string & | tableName,
|  | std::vector< TeDatabaseIndex > & | vecIndexes
| ) |  | `[virtual]`

Return a TeDatabaseIndex vector from a table.

Reimplemented from TeDatabase.

st_mysql* TeMySQL::getMySQL | ( |  | ) | `[inline]`

TeDatabasePortal * TeMySQL::getPortal | ( |  | ) | `[virtual]`

Returns a database portal.

A database portal is used to submit queries to the database and to navigate over the resulting record set

Implements TeDatabase.

string TeMySQL::getSQLTemporalWhere | ( | int | time1,
|  | int | time2,
|  | TeChronon | chr,
|  | TeTemporalRelation | rel,
|  | const string & | initialTime,
|  | const string & | finalTime
| ) |  | `[virtual]`

Return a string SQL to temporal where.

Reimplemented from TeDatabase.

string TeMySQL::getSQLTime | ( | const TeTime & |  | ) | const`[virtual]`

Returns a valid SQL time string.

Reimplemented from TeDatabase.

bool TeMySQL::inClauseValues | ( | const string & | query,
|  | const string & | attribute,
|  | vector< string > & | inClauseVector
| ) |  | `[virtual]`

Get the values that satisfy the query.

Reimplemented from TeDatabase.

bool TeMySQL::insertArc | ( | const string & | table,
|  | TeArc & | arc
| ) |  | `[virtual]`

Inserts an arc geometry in the database.

Implements TeDatabase.

bool TeMySQL::insertBlob | ( | const string & | tableName,
|  | const string & | columnBlob,
|  | const string & | whereClause,
|  | unsigned char * | data,
|  | int | size
| ) |  | `[virtual]`

Saves a large binary objects (BLOB) in a row table.

Implements TeDatabase.

bool TeMySQL::insertCell | ( | const string & | table,
|  | TeCell & | c
| ) |  | `[virtual]`

Implements TeDatabase.

int TeMySQL::insertId | ( |  | ) |

bool TeMySQL::insertLayer | ( | TeLayer * | layer | ) | `[virtual]`

Insert information about a layer.

Implements TeDatabase.

bool TeMySQL::insertLegend | ( | TeLegendEntry * | legend | ) | `[virtual]`

Inserts legend in the database.

Implements TeDatabase.

bool TeMySQL::insertLine | ( | const string & | table,
|  | TeLine2D & | l
| ) |  | `[virtual]`

Implements TeDatabase.

bool TeMySQL::insertLineSet | ( | const string & | table,
|  | TeLineSet & | ls
| ) |  | `[virtual]`

Reimplemented from TeDatabase.

bool TeMySQL::insertNode | ( | const string & | table,
|  | TeNode & | node
| ) |  | `[virtual]`

Implements TeDatabase.

bool TeMySQL::insertPoint | ( | const string & | table,
|  | TePoint & | p
| ) |  | `[virtual]`

Implements TeDatabase.

bool TeMySQL::insertPolygon | ( | const string & | table,
|  | TePolygon & | p
| ) |  | `[virtual]`

Inserts a polygon in a geometry table.

Implements TeDatabase.

bool TeMySQL::insertPolygonSet | ( | const string & | table,
|  | TePolygonSet & | ps
| ) |  | `[virtual]`

Inserts a polygon set in a geometry table.

Reimplemented from TeDatabase.

bool TeMySQL::insertProject | ( | TeProject * | project | ) | `[virtual]`

Insert information about a project.

Implements TeDatabase.

bool TeMySQL::insertProjection | ( | TeProjection * | proj | ) | `[virtual]`

Insert information about a geographical projection.

Implements TeDatabase.

bool TeMySQL::insertRasterBlock | ( | const string & | table,
|  | const string & | blockId,
|  | const TeCoord2D & | ll,
|  | const TeCoord2D & | ur,
|  | unsigned char * | buf,
|  | unsigned long | size,
|  | int | band = `0`,
|  | unsigned int | res = `1`,
|  | unsigned int | subband = `0`
| ) |  | `[virtual]`

Insert a raster block into the database.

Parameters:

  table | table name
  blockId | block unique identifier
  ll | block lower left coordinate
  ur | block upper right coordinate
  buf | block binary data
  size | block size
  band | block band
  res | block resolution factor
  subband | sub band definitiion

Implements TeDatabase.

bool TeMySQL::insertRelationInfo | ( | const int | tableId,
|  | const string & | tField,
|  | const string & | rTable,
|  | const string & | rField,
|  | int & | relId
| ) |  | `[virtual]`

Inserts information about a link to an external table.

Implements TeDatabase.

bool TeMySQL::insertRepresentation | ( | int | layerId,
|  | TeRepresentation & | rep
| ) |  | `[virtual]`

Inserts information about a geometrical representation.

Implements TeDatabase.

bool TeMySQL::insertTable | ( | TeTable & | table | ) | `[virtual]`

Saves a table and its contents in the database.

Reimplemented from TeDatabase.

bool TeMySQL::insertTableInfo | ( | int | layerId,
|  | TeTable & | table,
|  | const string & | user = `""`
| ) |  | `[virtual]`

Inserts information about an attribute table.

Implements TeDatabase.

bool TeMySQL::insertText | ( | const string & | table,
|  | TeText & | t
| ) |  | `[virtual]`

Implements TeDatabase.

bool TeMySQL::insertTheme | ( | TeAbstractTheme * | theme | ) | `[virtual]`

Inserts an abstract theme in the database.

Implements TeDatabase.

bool TeMySQL::insertThemeGroup | ( | TeViewTree * | tree | ) | `[virtual]`

Inserts a group of themes in the database.

Implements TeDatabase.

bool TeMySQL::insertThemeTable | ( | int | themeId,
|  | int | tableId,
|  | int | relationId,
|  | int | tableOrder
| ) |  | `[virtual]`

Inserts information about a table used by a theme.

Implements TeDatabase.

bool TeMySQL::insertView | ( | TeView * | view | ) | `[virtual]`

Inserts a view.

Implements TeDatabase.

bool TeMySQL::insertViewTree | ( | TeViewTree * | tree | ) | `[virtual]`

Recursive inserting of a view tree.

Implements TeDatabase.

bool TeMySQL::listDatabases | ( | std::vector< std::string > & | databaseList | ) | `[virtual]`

Returns a lista of databases.

Reimplemented from TeDatabase.

bool TeMySQL::newDatabase | ( | const string & | database,
|  | const string & | user,
|  | const string & | password,
|  | const string & | host,
|  | const int & | port = `-1`,
|  | bool | terralibModel = `true`,
|  | const std::string & | characterSet = `""`
| ) |  | `[virtual]`

Creates a new database and open a connection to it.

Implements TeDatabase.

bool TeMySQL::rollbackTransaction | ( |  | ) | `[virtual]`

Rollbacks a transaction.

Reimplemented from TeDatabase.

bool TeMySQL::setClientEncoding | ( | const std::string & | characterSet | ) | `[virtual]`

Sets the client encoding.

Reimplemented from TeDatabase.

bool TeMySQL::showDatabases | ( | const string & | ,
|  | const string & | ,
|  | const string & | ,
|  | vector< string > & | ,
|  | int | = `-1`
| ) |  | `[virtual]`

Show the server databases (only for MySQL, Oracle and PostgreSQL)

Reimplemented from TeDatabase.

bool TeMySQL::tableExist | ( | const string & | table | ) | `[virtual]`

Verifies if a table exist in the database.

Implements TeDatabase.

string TeMySQL::toUpper | ( | const string & | value | ) | `[virtual]`

Returns the SQL function for upper case.

Implements TeDatabase.

bool TeMySQL::updateLine | ( | const string & | table,
|  | TeLine2D & | l
| ) |  | `[virtual]`

Implements TeDatabase.

bool TeMySQL::updatePolygon | ( | const string & | table,
|  | TePolygon & | p
| ) |  | `[virtual]`

Updates a polygon in a geometry table.

Implements TeDatabase.

bool TeMySQL::updateTable | ( | TeTable & | table | ) | `[virtual]`

Updates a table and its contents in the database.

Reimplemented from TeDatabase.

## Friends And Related Function Documentation

friend class TeMySQLPortal`[friend]`

The documentation for this class was generated from the following files:

- E:/Projetos_Primeiro_Semestre_2012/TerraView/terralib/src/terralib/drivers/MySQL/TeMySQL.h
- E:/Projetos_Primeiro_Semestre_2012/TerraView/terralib/src/terralib/drivers/MySQL/TeMySQL.cpp

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines