23# include <mysql/config-win.h>
25#include <mysql_version.h>
33#include <kgenericfactory.h>
36#include "mysqldriver.h"
37#include "mysqlconnection.h"
38#include <kexidb/field.h>
39#include <kexidb/driver_p.h>
40#include <kexidb/utils.h>
62 d->features=IgnoreTransactions | CursorForward;
64 beh->ROW_ID_FIELD_NAME= "LAST_INSERT_ID()";
65 beh->ROW_ID_FIELD_RETURNS_LAST_AUTOINCREMENTED_VALUE= true;
66 beh->_1ST_ROW_READ_AHEAD_REQUIRED_TO_KNOW_IF_THE_RESULT_IS_EMPTY= false;
67 beh->USING_DATABASE_REQUIRED_TO_CONNECT= false;
68 beh->QUOTATION_MARKS_FOR_IDENTIFIER= '`';
69 beh->SQL_KEYWORDS = keywords;
73#if MYSQL_VERSION_ID < 40000
74 d->properties[ "client_library_version"] = MYSQL_SERVER_VERSION;
75 d->properties[ "default_server_encoding"] = MYSQL_CHARSET;
76#elif MYSQL_VERSION_ID < 50000
86 d->typeNames[Field::Date]= "DATE";
87 d->typeNames[Field::DateTime]= "DATETIME";
88 d->typeNames[Field::Time]= "TIME";
96MySqlDriver::~MySqlDriver()
120 const int old_length = str.length();
122 for ( i = 0; i < old_length; i++ ) {
123 const unsigned int ch = str[i].unicode();
124 if (ch == '\\' || ch == '\'' || ch == '"' || ch == '\n' || ch == '\r' || ch == '\t' || ch == '\b' || ch == '\0')
127 if (i >= old_length) {
128 return TQString::fromLatin1( "'") + str + TQString::fromLatin1( "'");
131 TQChar *new_string = new TQChar[ old_length * 3 + 1 ];
134 new_string[new_length++] = '\'';
135 for ( i = 0; i < old_length; i++, new_length++ ) {
136 const unsigned int ch = str[i].unicode();
138 new_string[new_length++] = '\\';
139 new_string[new_length] = '\\';
141 else if (ch <= '\'') {
143 new_string[new_length++] = '\\';
144 new_string[new_length] = '\'';
146 else if (ch == '"') {
147 new_string[new_length++] = '\\';
148 new_string[new_length] = '"';
150 else if (ch == '\n') {
151 new_string[new_length++] = '\\';
152 new_string[new_length] = 'n';
154 else if (ch == '\r') {
155 new_string[new_length++] = '\\';
156 new_string[new_length] = 'r';
158 else if (ch == '\t') {
159 new_string[new_length++] = '\\';
160 new_string[new_length] = 't';
162 else if (ch == '\b') {
163 new_string[new_length++] = '\\';
164 new_string[new_length] = 'b';
166 else if (ch == '\0') {
167 new_string[new_length++] = '\\';
168 new_string[new_length] = '0';
171 new_string[new_length] = str[i];
174 new_string[new_length] = str[i];
177 new_string[new_length++] = '\'';
178 TQString result(new_string, new_length);
179 delete [] new_string;
193 return TQCString( "'")+TQCString(str)
194 .replace( '\\', "\\\\" )
195 .replace( '\'', "\\''" )
196 .replace( '"', "\\\"" )
204 return TQString(str).replace( '`', "'");
208 return TQCString(str).replace( '`', "'");
211#include "mysqldriver.moc"
Database specific connection data, e.g. host, port.
Provides database connection, allowing queries and data modification.
Generic database abstraction.
bool isFileDriver() const
virtual bool isSystemObjectName(const TQString &n) const
virtual TQString escapeBLOB(const TQByteArray &array) const Escape BLOB value array.
virtual Connection * drv_createConnection(ConnectionData &conn_data)
virtual bool isSystemDatabaseName(const TQString &n) const
virtual TQString drv_escapeIdentifier(const TQString &str) const
virtual TQString escapeString(const TQString &str) const Escape a string for use as a value.
virtual bool drv_isSystemFieldName(const TQString &n) const
High-level database connectivity library with database backend drivers.
KEXI_DB_EXPORT TQString escapeBLOB(const TQByteArray &array, BLOBEscapingType type)
@ BLOBEscape0xHex escaping like 0x1FAD, used by mysql (hex numbers)
|