/ Prepare the SQL statement used to insert into a MySQL table. */ /
| 609 | /* Prepare the SQL statement used to insert into a MySQL table. */ |
| 610 | /***********************************************************************/ |
| 611 | int MYSQLC::PrepareSQL(PGLOBAL g, const char *stmt) |
| 612 | { |
| 613 | if (!m_DB) { |
| 614 | strcpy(g->Message, "MySQL not connected"); |
| 615 | return -4; |
| 616 | } else if (m_Stmt) |
| 617 | return -1; // should not append |
| 618 | |
| 619 | #if defined(ALPHA) |
| 620 | if (!(m_Stmt = mysql_prepare(m_DB, stmt, strlen(stmt)))) { |
| 621 | |
| 622 | snprintf(g->Message, sizeof(g->Message), "mysql_prepare failed: %s [%s]", |
| 623 | mysql_error(m_DB), stmt); |
| 624 | return -1; |
| 625 | } // endif m_Stmt |
| 626 | |
| 627 | // Return the parameter count from the statement |
| 628 | return mysql_param_count(m_Stmt); |
| 629 | #else // !ALPHA |
| 630 | if (!(m_Stmt = mysql_stmt_init(m_DB))) { |
| 631 | strcpy(g->Message, "mysql_stmt_init(), out of memory"); |
| 632 | return -2; |
| 633 | } // endif m_Stmt |
| 634 | |
| 635 | if (mysql_stmt_prepare(m_Stmt, stmt, strlen(stmt))) { |
| 636 | snprintf(g->Message, sizeof(g->Message), "mysql_stmt_prepare() failed: (%d) %s", |
| 637 | mysql_stmt_errno(m_Stmt), mysql_stmt_error(m_Stmt)); |
| 638 | return -3; |
| 639 | } // endif prepare |
| 640 | |
| 641 | // Return the parameter count from the statement |
| 642 | return mysql_stmt_param_count(m_Stmt); |
| 643 | #endif // !ALPHA |
| 644 | } // end of PrepareSQL |
| 645 | |
| 646 | /***********************************************************************/ |
| 647 | /* Bind the parameter buffers. */ |
no test coverage detected