Changeset View
Changeset View
Standalone View
Standalone View
src/drivers/mysql/MysqlPreparedStatement.cpp
Show First 20 Lines • Show All 131 Lines • ▼ Show 20 Line(s) | 129 | if (ok) { | |||
---|---|---|---|---|---|
132 | else if (field->type() == KDbField::ShortInteger) | 132 | else if (field->type() == KDbField::ShortInteger) | ||
133 | m_mysqlBind[arg].buffer_type = MYSQL_TYPE_SHORT; | 133 | m_mysqlBind[arg].buffer_type = MYSQL_TYPE_SHORT; | ||
134 | else if (field->type() == KDbField::Integer) | 134 | else if (field->type() == KDbField::Integer) | ||
135 | m_mysqlBind[arg].buffer_type = MYSQL_TYPE_LONG; | 135 | m_mysqlBind[arg].buffer_type = MYSQL_TYPE_LONG; | ||
136 | 136 | | |||
137 | m_mysqlBind[arg].is_null = (my_bool*)0; | 137 | m_mysqlBind[arg].is_null = (my_bool*)0; | ||
138 | m_mysqlBind[arg].length = 0; | 138 | m_mysqlBind[arg].length = 0; | ||
139 | 139 | | |||
140 | res = sqlite3_bind_int(prepared_st_handle, arg, intValue); | 140 | res = sqlite3_bind_int(prepared_st_handle, arg, intValue); | ||
anthonyfieroni: sqlite bind in mysql driver - it looks quite strange :) It's not only here. | |||||
Thanks, currently it's ifdefed out, KDB_USE_MYSQL_STMT is off. Code kept for reference here and changes made mechanically. staniek: Thanks, currently it's ifdefed out, KDB_USE_MYSQL_STMT is off. Code kept for reference here and… | |||||
141 | if (SQLITE_OK != res) { | 141 | if (SQLITE_OK != res) { | ||
142 | //! @todo msg? | 142 | //! @todo msg? | ||
143 | return false; | 143 | return false; | ||
144 | } | 144 | } | ||
145 | } else | 145 | } else | ||
146 | BIND_NULL; | 146 | BIND_NULL; | ||
147 | break; | 147 | break; | ||
148 | } | 148 | } | ||
▲ Show 20 Lines • Show All 78 Lines • ▼ Show 20 Line(s) | 226 | if (SQLITE_OK != res) { | |||
227 | //! @todo msg? | 227 | //! @todo msg? | ||
228 | return false; | 228 | return false; | ||
229 | } | 229 | } | ||
230 | } //switch | 230 | } //switch | ||
231 | return true; | 231 | return true; | ||
232 | } | 232 | } | ||
233 | #endif | 233 | #endif | ||
234 | 234 | | |||
235 | KDbSqlResult* MysqlPreparedStatement::execute( | 235 | QSharedPointer<KDbSqlResult> MysqlPreparedStatement::execute(KDbPreparedStatement::Type type, | ||
236 | KDbPreparedStatement::Type type, | | |||
237 | const KDbField::List& selectFieldList, | 236 | const KDbField::List &selectFieldList, | ||
238 | KDbFieldList* insertFieldList, | 237 | KDbFieldList *insertFieldList, | ||
239 | const KDbPreparedStatementParameters& parameters, bool *resultOwned) | 238 | const KDbPreparedStatementParameters ¶meters) | ||
240 | { | 239 | { | ||
241 | Q_UNUSED(selectFieldList); | 240 | Q_UNUSED(selectFieldList); | ||
241 | QSharedPointer<KDbSqlResult> result; | ||||
242 | #ifdef KDB_USE_MYSQL_STMT | 242 | #ifdef KDB_USE_MYSQL_STMT | ||
243 | if (!m_statement || m_realParamCount <= 0) | 243 | if (!m_statement || m_realParamCount <= 0) | ||
244 | return false; | 244 | return false; | ||
245 | if (mysql_stmt_errno(m_statement) == CR_SERVER_LOST) { | 245 | if (mysql_stmt_errno(m_statement) == CR_SERVER_LOST) { | ||
246 | //sanity: connection lost: reconnect | 246 | //sanity: connection lost: reconnect | ||
247 | //! @todo KDbConnection should be reconnected as well! | 247 | //! @todo KDbConnection should be reconnected as well! | ||
248 | done(); | 248 | done(); | ||
249 | if (!init()) { | 249 | if (!init()) { | ||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Line(s) | 299 | if (type == KDbPreparedStatement::InsertStatement) { | |||
300 | const int missingValues = insertFieldList->fieldCount() - parameters.count(); | 300 | const int missingValues = insertFieldList->fieldCount() - parameters.count(); | ||
301 | KDbPreparedStatementParameters myParameters(parameters); | 301 | KDbPreparedStatementParameters myParameters(parameters); | ||
302 | if (missingValues > 0) { | 302 | if (missingValues > 0) { | ||
303 | //! @todo can be more efficient | 303 | //! @todo can be more efficient | ||
304 | for (int i = 0; i < missingValues; i++) { | 304 | for (int i = 0; i < missingValues; i++) { | ||
305 | myParameters.append(QVariant()); | 305 | myParameters.append(QVariant()); | ||
306 | } | 306 | } | ||
307 | } | 307 | } | ||
308 | KDbSqlResult* result; | 308 | result = connection->insertRecord(insertFieldList, myParameters); | ||
309 | if (connection->insertRecord(insertFieldList, myParameters, &result)) { | | |||
310 | *resultOwned = false; | | |||
311 | return result; | | |||
312 | } | | |||
313 | return nullptr; | | |||
314 | } | 309 | } | ||
315 | //! @todo support select | 310 | //! @todo support select | ||
316 | #endif // !KDB_USE_MYSQL_STMT | 311 | #endif // !KDB_USE_MYSQL_STMT | ||
317 | return nullptr; | 312 | return result; | ||
318 | } | 313 | } |
sqlite bind in mysql driver - it looks quite strange :) It's not only here.