#include <stdio.h> #include <stdlib.h> #include <string.h> #include <mysql.h>
#define INSERT_QUERY "INSERT INTO a(a) VALUES(?)" #if !defined(MC68000) && !defined(DS90) char *strmov(register char *dst, register const char *src) { while ((*dst++ = *src++)) ; return dst-1; } #else
char *strmov(dst, src), char *dst, *src; { asm(" movl 4(a7),a1 "); asm(" movl 8(a7),a0 "); asm(".L4: movb (a0)+,(a1)+ "); asm(" jne .L4 "); asm(" movl a1,d0 "); asm(" subql #1,d0 "); }
#endif
int main(int argc, char **argv) { if (argc != 2) { printf("%s digit\n",argv[0]); return(1); } char *server="localhost",*user="root",*password=""; MYSQL *conn; MYSQL_RES *res; MYSQL_ROW row; conn = mysql_init(NULL); if (!mysql_real_connect(conn, server, user, password, "test", 0, NULL, 0)) { fprintf(stderr, "%s\n", mysql_error(conn)); exit(EXIT_FAILURE); } MYSQL_STMT *stmt = mysql_stmt_init(conn); mysql_stmt_prepare(stmt, INSERT_QUERY, strlen(INSERT_QUERY));
MYSQL_BIND bind[1]; memset(bind, 0, sizeof(bind)); unsigned long length;
char query[100] = {0};
char *pos = query; strcpy(query,argv[1]);
bind[0].buffer_type= MYSQL_TYPE_BLOB; bind[0].buffer= query; bind[0].is_null= 0; bind[0].length= &length; /* Bind the buffers */ mysql_stmt_bind_param(stmt, bind); /* Supply data in chunks to server */ mysql_stmt_send_long_data(stmt,0, pos, strlen(query)); mysql_stmt_execute(stmt); mysql_stmt_close(stmt); }
|