* Just like insert, but replace the row if it exists. * \param _h database handle * \param _k key names * \param _v values of the keys that must match * \param _n number of key=value pairs * \return zero on success, negative value on failure */
| 1443 | * \return zero on success, negative value on failure |
| 1444 | */ |
| 1445 | int db_mysql_replace(const db_con_t* _h, const db_key_t* _k, const db_val_t* _v, const int _n) |
| 1446 | { |
| 1447 | int ret; |
| 1448 | |
| 1449 | if (CON_HAS_PS(_h)) { |
| 1450 | if (CON_HAS_UNINIT_PS(_h)||!has_stmt_ctx(_h,&(CON_MYSQL_PS(_h)->ctx))){ |
| 1451 | ret = db_do_replace(_h, _k, _v, _n, db_mysql_val2str, |
| 1452 | db_mysql_submit_dummy_query); |
| 1453 | if (ret != 0) { |
| 1454 | CON_RESET_CURR_PS(_h); |
| 1455 | return ret; |
| 1456 | } |
| 1457 | } |
| 1458 | ret = db_mysql_do_prepared_query(_h, &query_holder, _v, _n, NULL, 0); |
| 1459 | CON_RESET_CURR_PS(_h); |
| 1460 | return ret; |
| 1461 | } |
| 1462 | return db_do_replace(_h, _k, _v, _n, db_mysql_val2str, |
| 1463 | db_mysql_submit_query); |
| 1464 | } |
| 1465 | |
| 1466 | |
| 1467 | /** |
nothing calls this directly
no test coverage detected