存储过程如下:
DELIMITER $$
USE `gface_taisau`$$
DROP PROCEDURE IF EXISTS `p_InsertFace`$$
CREATE DEFINER=`root`@`localhost` PROCEDURE `p_InsertFace`(
IN Id BIGINT(8),
IN UserID BIGINT(8),
IN FeaLen SMALLINT(2),
IN Fea BLOB,
IN ImgUrl CHAR(64),
IN Type1 INT(4),
IN Type2 INT(4),
IN Type3 INT(4),
IN Type4 CHAR(32),
IN Remarks CHAR(64),
OUT OID BIGINT(8))
BEGIN
DECLARE l_Id BIGINT(8);
SET l_Id= 0;
IF (Id>0) THEN
SET l_Id=Id;
END IF;
INSERT INTO t_face
(ID,
UserID,
FeaLen,
Fea,
ImgUrl,
Type1,
Type2,
Type3,
Type4,
Stamp,
IsDel,
UpdateTime,
Remarks
)
VALUES
(l_Id,
UserID,
FeaLen,
Fea,
ImgUrl,
Type1,
Type2,
Type3,
Type4,
NOW(),
0,
NOW(),
Remarks
);
IF(l_Id=0) THEN
SET OID=LAST_INSERT_ID();
END IF;
END$$
DELIMITER ;
用到的结构体如下
#define MAX_FEA_LEN 10240 //定义10k
#define MAX_URL_LEN 200
//图片信息
typedef struct _FACE_INFO
{
//ULONGLONG nID;
ULONGLONG nID;
ULONGLONG nUserID;
DWORD nFeaLen;
TCHAR szFea[MAX_FEA_LEN];
TCHAR szUrl[MAX_URL_LEN];
DWORD nType1;
DWORD nType2;
DWORD nType3;
TCHAR szType4[32];
TCHAR szStamp[20];//2012-08-08 08:08:08
TCHAR szRemarks[64];
_FACE_INFO()
{
nID = 0;
nUserID = 0;
nFeaLen = 0;
memset(szFea,0,sizeof(szFea));
memset(szUrl,0,sizeof(szUrl));
nType1 = 0;
nType2 = 0;
nType3 = 0;
memset(szType4,0,sizeof(szType4));
memset(szStamp,0,sizeof(szStamp));
memset(szRemarks,0,sizeof(szRemarks));
}
}FACE_INFO, *PFACE_INFO;
//调研代码如下
HRESULT CFaceDB::RegFaceP(FACE_INFO info,ULONGLONG & nID)
{
MYSQL_STMT * stmt_mysql = mysql_stmt_init(m_pMysql);
try
{
MYSQL_BIND bind[11];
memset(bind, 0, sizeof(bind));
bind[0].buffer_type = MYSQL_TYPE_LONGLONG;
bind[0].buffer = (unsigned char*)&nID;
bind[0].buffer_length = (unsigned long)sizeof(nID);
bind[0].length = 0;
bind[1].buffer_type = MYSQL_TYPE_LONGLONG;
bind[1].buffer = (unsigned char*)&info.nUserID;
bind[1].buffer_length = (unsigned long)sizeof(info.nUserID);
bind[1].length = 0;
bind[2].buffer_type = MYSQL_TYPE_SHORT;
bind[2].buffer = (unsigned char*)&info.nFeaLen;
bind[2].buffer_length = (unsigned long)sizeof(info.nFeaLen);
bind[2].length = 0;
unsigned long nFeaLen = info.nFeaLen;
bind[3].buffer_type = MYSQL_TYPE_BLOB; //特征值
bind[3].buffer = (unsigned char*)info.szFea;
bind[3].buffer_length = (unsigned long)nFeaLen;
bind[3].length = &nFeaLen;
unsigned long nUrlLen = strlen(info.szUrl);
bind[4].buffer_type = MYSQL_TYPE_STRING; //ImgUrl
bind[4].buffer = (char*)info.szUrl;
bind[4].buffer_length = 64;
bind[4].length = &nUrlLen;
bind[5].buffer_type = MYSQL_TYPE_LONG; //type1
bind[5].buffer = (unsigned char*)&info.nType1;
bind[5].buffer_length = (unsigned long)sizeof(info.nType1);
bind[5].length = 0;
bind[6].buffer_type = MYSQL_TYPE_LONG; //type2
bind[6].buffer = (unsigned char*)&info.nType2;
bind[6].buffer_length = (unsigned long)sizeof(info.nType2);
bind[6].length = 0;
bind[7].buffer_type = MYSQL_TYPE_LONG; //type3
bind[7].buffer = (unsigned char*)&info.nType3;
bind[7].buffer_length = (unsigned long)sizeof(info.nType3);
bind[7].length = 0;
unsigned long nType4Len = strlen(info.szType4);
bind[8].buffer_type = MYSQL_TYPE_STRING; //typ4
bind[8].buffer = (char*)info.szType4;
bind[8].buffer_length = 32;
bind[8].length = &nType4Len;
unsigned long nRemarksLen = strlen(info.szRemarks);
bind[9].buffer_type = MYSQL_TYPE_STRING; //remarks
bind[9].buffer = (char*)info.szRemarks;
bind[9].buffer_length = 64;
//bind[9].is_null = 0;
bind[9].length = &nRemarksLen;
bind[10].buffer_type = MYSQL_TYPE_LONGLONG;
bind[10].buffer = (unsigned char*)&nID;
bind[10].buffer_length = (unsigned long)sizeof(nID);
bind[10].length = 0;
char szInsert[1024] = {0};
strcpy_s( szInsert,1024,"CALL P_INSERTFACE(?,?,?,?,?,?,?,?,?,?,@1);");
//strcpy_s( szInsert,1024,"CALL P_INSERTFACE(?,?,?);");
mysql_stmt_prepare(stmt_mysql, szInsert, (unsigned long)strlen(szInsert));
mysql_stmt_bind_param(stmt_mysql, bind);
mysql_stmt_bind_result(stmt_mysql,bind + 10);
if( mysql_stmt_execute(stmt_mysql)==0 )
{
CString cmdStr=_T("SELECT @1");
int nRet = mysql_query(m_pMysql, cmdStr);
if(0 == nRet)
{
MYSQL_RES* pResult = NULL;
pResult = mysql_store_result(m_pMysql);
if (pResult)
{
MYSQL_ROW rdRow;
rdRow = mysql_fetch_row(pResult);
nID = StrToLONG64(CString(rdRow[0]));//自定义函数 该函数是吧字符串转64位整型
}
mysql_free_result(pResult);
}
mysql_stmt_close(stmt_mysql);
return S_OK;
}
else
{
mysql_stmt_close(stmt_mysql);
return S_FALSE;
}
}
catch(...)
{
mysql_stmt_close(stmt_mysql);
}
return S_FALSE;
}

InnoDBBufferPool reduces disk I/O by caching data and indexing pages, improving database performance. Its working principle includes: 1. Data reading: Read data from BufferPool; 2. Data writing: After modifying the data, write to BufferPool and refresh it to disk regularly; 3. Cache management: Use the LRU algorithm to manage cache pages; 4. Reading mechanism: Load adjacent data pages in advance. By sizing the BufferPool and using multiple instances, database performance can be optimized.

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages have advantages in their respective fields such as data analytics, enterprise applications, and system programming.

MySQL is worth learning because it is a powerful open source database management system suitable for data storage, management and analysis. 1) MySQL is a relational database that uses SQL to operate data and is suitable for structured data management. 2) The SQL language is the key to interacting with MySQL and supports CRUD operations. 3) The working principle of MySQL includes client/server architecture, storage engine and query optimizer. 4) Basic usage includes creating databases and tables, and advanced usage involves joining tables using JOIN. 5) Common errors include syntax errors and permission issues, and debugging skills include checking syntax and using EXPLAIN commands. 6) Performance optimization involves the use of indexes, optimization of SQL statements and regular maintenance of databases.

MySQL is suitable for beginners to learn database skills. 1. Install MySQL server and client tools. 2. Understand basic SQL queries, such as SELECT. 3. Master data operations: create tables, insert, update, and delete data. 4. Learn advanced skills: subquery and window functions. 5. Debugging and optimization: Check syntax, use indexes, avoid SELECT*, and use LIMIT.

MySQL efficiently manages structured data through table structure and SQL query, and implements inter-table relationships through foreign keys. 1. Define the data format and type when creating a table. 2. Use foreign keys to establish relationships between tables. 3. Improve performance through indexing and query optimization. 4. Regularly backup and monitor databases to ensure data security and performance optimization.

MySQL is an open source relational database management system that is widely used in Web development. Its key features include: 1. Supports multiple storage engines, such as InnoDB and MyISAM, suitable for different scenarios; 2. Provides master-slave replication functions to facilitate load balancing and data backup; 3. Improve query efficiency through query optimization and index use.

SQL is used to interact with MySQL database to realize data addition, deletion, modification, inspection and database design. 1) SQL performs data operations through SELECT, INSERT, UPDATE, DELETE statements; 2) Use CREATE, ALTER, DROP statements for database design and management; 3) Complex queries and data analysis are implemented through SQL to improve business decision-making efficiency.

The basic operations of MySQL include creating databases, tables, and using SQL to perform CRUD operations on data. 1. Create a database: CREATEDATABASEmy_first_db; 2. Create a table: CREATETABLEbooks(idINTAUTO_INCREMENTPRIMARYKEY, titleVARCHAR(100)NOTNULL, authorVARCHAR(100)NOTNULL, published_yearINT); 3. Insert data: INSERTINTObooks(title, author, published_year)VA


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

WebStorm Mac version
Useful JavaScript development tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.