From 56f2bdb24bf13c345e7b238857c39bd2ea6a925a Mon Sep 17 00:00:00 2001
From: pans <pans@454eff88-639b-444f-9e54-f578c98de674>
Date: 星期四, 05 一月 2017 16:29:09 +0800
Subject: [PATCH] 

---
 RtspFace/demo/src/DBuntil.cpp |   35 ++++++++++++++++++++++++-----------
 1 files changed, 24 insertions(+), 11 deletions(-)

diff --git a/RtspFace/demo/src/DBuntil.cpp b/RtspFace/demo/src/DBuntil.cpp
index 3fe23c9..1c61e1a 100644
--- a/RtspFace/demo/src/DBuntil.cpp
+++ b/RtspFace/demo/src/DBuntil.cpp
@@ -3,15 +3,14 @@
 #include <cstdio>
 #include <iostream>
 
-
-MYSQL myCont;
-MYSQL_RES *result;
-MYSQL_ROW sql_row;
-
-DBuntil::DBuntil() {}
+DBuntil::DBuntil() {
+	
+}
 
 DBuntil::DBuntil(my_db mydb)
 {
+	std::cout<<"DBuntil(my_db mydb) start"<<std::endl;
+	
 	if(mysql_init(&myCont)!=NULL)
 	{
 		std::cout<<"init succeed"<<std::endl;
@@ -25,6 +24,8 @@
 	}
 	else
 		std::cout<<"mysql_real_connect failed"<<std::endl;
+	
+	std::cout<<"DBuntil(my_db mydb) end"<<std::endl;
 }
 
 DBuntil::~DBuntil()
@@ -49,22 +50,34 @@
 bool DBuntil::db_select(person* per)
 {
 	std::cout<<"db_select start"<<std::endl;
-	sprintf( sql, "select a.p_id,b.`name`,b.img from face_person a,user_info b where a.face_id = %d AND a.p_id = b.pid " ,per->f_id );
-
-	mysql_query(&myCont, "SET NAMES utf8"); //璁剧疆缂栫爜鏍煎紡
+	sprintf( sql, "select a.p_id,b.name,b.img from face_person a,user_info b where a.face_id = %d AND a.p_id = b.pid " ,per->f_id );
+	std::cout<<"==========start============"<<std::endl;
+	std::cout<<"per->f_id="<<per->f_id<<std::endl;
+	std::cout<<sql<<std::endl;
+	std::cout<<"==========end=============="<<std::endl;
+	if(!mysql_query(&myCont, "SET NAMES utf8"))//璁剧疆缂栫爜鏍煎紡
+	{
+		std::cout<<"SET NAMES utf8"<<std::endl;
+	}else
+		std::cout<<"SET NAMES utf8 failed"<<std::endl;
 	res = mysql_query(&myCont,sql);//鏌ヨ
 	if (!res)
 	{
 		result = mysql_store_result(&myCont);
-		if (result)
+		if (result != NULL)
 		{
 			while (sql_row = mysql_fetch_row(result))
 			{
 				//鑾峰彇鍏蜂綋鐨勬暟鎹�
 				per->p_id = atoi( sql_row[0]);
 				per->name = sql_row[1];
+
+				std::cout<<"per->p_id="<<per->p_id<<std::endl;
+				std::cout<<"per->name="<<per->name<<std::endl;
+				std::cout<<"per->f_id="<<per->f_id<<std::endl;
 			}
-		}
+		}else
+			std::cout<<"result is null?"<<std::endl;
 	}
 	else
 	{

--
Gitblit v1.8.0