Changeset View
Changeset View
Standalone View
Standalone View
src/drivers/mysql/MysqlConnection.cpp
Show First 20 Lines • Show All 135 Lines • ▼ Show 20 Line(s) | |||||
136 | } | 136 | } | ||
137 | 137 | | |||
138 | bool MysqlConnection::drv_createDatabase(const QString &dbName) | 138 | bool MysqlConnection::drv_createDatabase(const QString &dbName) | ||
139 | { | 139 | { | ||
140 | const QString storedDbName(d->lowerCaseTableNames ? dbName.toLower() : dbName); | 140 | const QString storedDbName(d->lowerCaseTableNames ? dbName.toLower() : dbName); | ||
141 | mysqlDebug() << storedDbName; | 141 | mysqlDebug() << storedDbName; | ||
142 | // mysql_create_db deprecated, use SQL here. | 142 | // mysql_create_db deprecated, use SQL here. | ||
143 | // db names are lower case in mysql | 143 | // db names are lower case in mysql | ||
144 | return drv_executeVoidSQL(KDbEscapedString("CREATE DATABASE %1").arg(escapeIdentifier(storedDbName))); | 144 | return drv_executeSql(KDbEscapedString("CREATE DATABASE %1").arg(escapeIdentifier(storedDbName))); | ||
145 | } | 145 | } | ||
146 | 146 | | |||
147 | bool MysqlConnection::drv_useDatabase(const QString &dbName, bool *cancelled, KDbMessageHandler* msgHandler) | 147 | bool MysqlConnection::drv_useDatabase(const QString &dbName, bool *cancelled, KDbMessageHandler* msgHandler) | ||
148 | { | 148 | { | ||
149 | Q_UNUSED(cancelled); | 149 | Q_UNUSED(cancelled); | ||
150 | Q_UNUSED(msgHandler); | 150 | Q_UNUSED(msgHandler); | ||
151 | //! @todo is here escaping needed? | 151 | //! @todo is here escaping needed? | ||
152 | const QString storedDbName(d->lowerCaseTableNames ? dbName.toLower() : dbName); | 152 | const QString storedDbName(d->lowerCaseTableNames ? dbName.toLower() : dbName); | ||
Show All 9 Lines | |||||
162 | //! @todo free resources, as far as I know, mysql doesn't support that | 162 | //! @todo free resources, as far as I know, mysql doesn't support that | ||
163 | return true; | 163 | return true; | ||
164 | } | 164 | } | ||
165 | 165 | | |||
166 | bool MysqlConnection::drv_dropDatabase(const QString &dbName) | 166 | bool MysqlConnection::drv_dropDatabase(const QString &dbName) | ||
167 | { | 167 | { | ||
168 | //! @todo is here escaping needed? | 168 | //! @todo is here escaping needed? | ||
169 | const QString storedDbName(d->lowerCaseTableNames ? dbName.toLower() : dbName); | 169 | const QString storedDbName(d->lowerCaseTableNames ? dbName.toLower() : dbName); | ||
170 | return drv_executeVoidSQL(KDbEscapedString("DROP DATABASE %1").arg(escapeIdentifier(storedDbName))); | 170 | return drv_executeSql(KDbEscapedString("DROP DATABASE %1").arg(escapeIdentifier(storedDbName))); | ||
171 | } | 171 | } | ||
172 | 172 | | |||
173 | KDbSqlResult* MysqlConnection::drv_executeSQL(const KDbEscapedString& sql) | 173 | KDbSqlResult* MysqlConnection::drv_prepareSql(const KDbEscapedString& sql) | ||
174 | { | 174 | { | ||
175 | if (!drv_executeVoidSQL(sql)) { | 175 | if (!drv_executeSql(sql)) { | ||
176 | return nullptr; | 176 | return nullptr; | ||
177 | } | 177 | } | ||
178 | MYSQL_RES *data = mysql_use_result(d->mysql); // more optimal than mysql_store_result | 178 | MYSQL_RES *data = mysql_use_result(d->mysql); // more optimal than mysql_store_result | ||
179 | //! @todo use mysql_error() | 179 | //! @todo use mysql_error() | ||
180 | return new MysqlSqlResult(this, data); | 180 | return new MysqlSqlResult(this, data); | ||
181 | } | 181 | } | ||
182 | 182 | | |||
183 | bool MysqlConnection::drv_executeVoidSQL(const KDbEscapedString& sql) | 183 | bool MysqlConnection::drv_executeSql(const KDbEscapedString& sql) | ||
184 | { | 184 | { | ||
185 | if (!d->executeVoidSQL(sql)) { | 185 | if (!d->executeSql(sql)) { | ||
186 | storeResult(); | 186 | storeResult(); | ||
187 | return false; | 187 | return false; | ||
188 | } | 188 | } | ||
189 | return true; | 189 | return true; | ||
190 | } | 190 | } | ||
191 | 191 | | |||
192 | QString MysqlConnection::serverResultName() const | 192 | QString MysqlConnection::serverResultName() const | ||
193 | { | 193 | { | ||
Show All 18 Lines |